Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Dim dtAdapter As System.Data.SqlClient.SqlDataAdapter
Dim dt As New DataTable
Dim objConn As New SqlConnection
Dim ds As New DataSet
Dim objCmd As New SqlCommand
Dim strConnString, strSQL, strqr As String
strConnString = "Server=IT-04S\SQLEXPRESS;UID=TestVB;PASSWORD=11111;database=TestVB;Max Pool Size=400;Connect Timeout=600;"
objConn = New System.Data.SqlClient.SqlConnection(strConnString)
objConn.Open()
Dim intNumRows As Integer
strSQL = "SELECT sum(" & Me.ListBox1.Text & ") FROM DATASale WHERE พนง#ขาย = '" & Me.ComboBox1.Text & "'"
objCmd = New SqlCommand(strSQL, objConn)
intNumRows = objCmd.ExecuteScalar()
Label1.Text = intNumRows
'''''''
strqr = "UPDATE ReportSL SET '" & Me.ListBox2.Text & "' = '" & Me.Label1.Text & "' WHERE IdEmp = '" & Me.ComboBox1.Text & "' "
objCmd = New SqlCommand
With objCmd
.Connection = objConn
.CommandText = strqr
.CommandType = CommandType.Text
End With
'Me.pnlAdd.Visible = False
Try
objCmd.ExecuteNonQuery()
Me.Label2.Text = "Record Updated"
Me.Label2.Visible = True
Catch ex As Exception
Me.Label2.Text = "Record can not update"
End Try
End Sub