Public Sub SearchUser()
Try
conn = New MySqlConnection()
conn.ConnectionString = "server=localhost; user id=root; database=eps"
conn.Open()
sqlquery = "SELECT username FROM pass WHERE username = '" & cmbUserName.Text & "'"
Dim myCommand As New MySqlCommand()
myCommand.Connection = conn
myCommand.CommandText = sqlquery
'start query
myAdapter.SelectCommand = myCommand
Dim myData As MySqlDataReader
myData = myCommand.ExecuteReader()
myData.Read()
cmbUserName.Text = CStr(myData("username"))
Catch ex As Exception
MsgBox("User Name not found!")
Finally
conn.Close()
End Try
End Sub
When i click the search button, why can not display the data from database into combobox? What's wrong with my code? Anyone can help me solve this problem?