the same thing in the first click, this is my code....
Private Sub txtNama_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles txtNama.MouseClick
Dim ds As New DataSet
Dim dt As New DataTable
Dim a As String = "SELECT NAMA, KURSUS FROM DAFTARPELAJAR WHERE NDP = @NDP"
Dim b As New OleDbDataAdapter(acscmd)
acscmd.CommandText = a
txtNama.Text = dt.Rows(0).Item(0)
txtKursus.Text = dt.Rows(0).Item(1)
this code only run in the first click, i dont know why.
Your first problem is that you have to use ? for parameters when you use OleDb so your query should be
Dim a As String = "SELECT NAMA, KURSUS FROM DAFTARPELAJAR WHERE NDP = ?"
When I try the code on my database (with the corrected query) it works just fine. If I type a new value in txtNDP and click on txtNama then the control gets updated. Incidentally, what you are doing is not called binding. You are just fetching a value and populating the textbox manually. You might as well just use a datareader.
oh, ok....thank for you information about populating the the textbox, i already try the query that you give, but after i run the code it will show error on line b.fill(dt) = Data type mismatch in criteria expression. That why im using parameter to solve the error.
i also try to clear the txtnama.text but when new ndp is filled and click at txtnama it still show the 1st clicked data.
its like the event running on 1st click only.
Dim Adapter As New OleDbDataAdapter
Dim Command As New OleDbCommand
Dim xFrom As String = dtpFrom.Value.ToString.Substring(0, dtpFrom.Value.ToString.IndexOf(" "))
Dim xTo As String = dtpTo.Value.ToString.Substring(0, dtpTo.Value.ToString.IndexOf(" "))
sqlQuery = MainQuery ...