Trying to make drop down combobox, select all in column from a sql table. Seems like its not working, can someone please help me with this problem?The code is below..
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim SQLSelect As New SqlCommand
Dim SQLDR As SqlDataReader
Dim SQLConnection As New SqlConnection
SQLConnection.ConnectionString = "Server=11.52.122.2;UID=admin;PWD=testsql;Database=General Log;Integrated Security=False"
SQLSelect.Connection = SQLConnection
Try
SQLConnection.Open()
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
SQLSelect.CommandText = " SELECT [Part Number] FROM [ITEM_TABLE]"
SQLDR = SQLSelect.ExecuteReader
While SQLDR.Read
ComboBox1.Text = SQLDR.Item(0)
End While
SQLConnection.Close()
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim SQLSelect As New SqlCommand
Dim SQLDR As SqlDataReader
Dim SQLConnection As New SqlConnection
SQLConnection.ConnectionString = "Server=11.52.122.2;UID=admin;PWD=testsql;Database=General Log;Integrated Security=False"
SQLSelect.Connection = SQLConnection
Try
SQLConnection.Open()
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
SQLSelect.CommandText = " SELECT [Part Number] FROM [ITEM_TABLE]"
SQLDR = SQLSelect.ExecuteReader
While SQLDR.Read
ComboBox1.Text = SQLDR.Item(0)
End While
SQLConnection.Close()
End Sub