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 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 = strSQL
End Sub