Hello and good day to all...
I created a database contains "Down Time" table inside this table there is 'employee number' , 'no material PC' and other columns and now I am programming in Visual Basic 2010 and I want to retrieve all the sum of all values that entered into 'no material PC' column in one text box for all employees who entered a record for this column.
Thanks a lot I really appreciate your help
This is my code
//
Private Sub LoudData()
Dim myConnection As SqlConnection
Dim cmd As SqlClient.SqlCommand
Dim DR As SqlClient.SqlDataReader
Dim strQuery As String
'Loss Time No Material PC
myConnection = New SqlConnection("server=SHHW0037\METSDATABASE;uid=ME TSDATABASE;pwd=METSDB;database=METS")
strQuery = ("If EXISTS (SELECT * FROM DownTime WHERE Process ='" TextBox1.Text "' AND Date ='" DateTimePicker1.Value.ToString("MM/dd/yyyy ") "') SELECT NoMaterialPC FROM DownTime WHERE Process ='" TextBox1.Text "' AND Date ='" DateTimePicker1.Value.ToString("MM/dd/yyyy") "'")
Try
myConnection.Open()
cmd = New SqlClient.SqlCommand(strQuery, myConnection)
DR = cmd.ExecuteReader()
While DR.Read()
TextBox3.Text = CStr(DR.GetInt32(0))
End While
DR.Close()
myConnection.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
//