Hello guys,
I am still encountering a problem regarding my combobox. I am trying to populate it from my MySQL table but I am unable to so far....
Dim connectionstring As String
Dim dbCon As MySqlConnection
Dim strQuery As String = ""
Dim SQLCmd As MySqlCommand
Dim DR As MySqlDataReader
Dim mysqladapter As MySqlDataAdapter
Dim dt As DataTable
Private Sub cmbName_DropDown(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbName.DropDown
Try
'dbCon = New MySqlConnection("Server = localhost; Database=test;uid=root;Pwd=")
dbCon = New MySqlConnection("SERVER=localhost;DATABASE=test;")
strQuery = "SELECT Name FROM students;"
SQLCmd = New MySqlCommand(strQuery, dbCon)
dbCon.Open()
DR = SQLCmd.ExecuteReader
mysqladapter.Fill(dt)
cmbName.DataSource = dt
cmbName.ValueMember = "Name"
DR.Close()
dbCon.Close()
Catch ex As Exception
MsgBox("Failure to communicate!" & vbCrLf & vbCrLf & ex.Message)
End Try
End Sub