views:

38

answers:

0

I've tried loading a mysql data into vb.net data grid view and it is dynamic. Dynamic meaning, it changes its contents whenever I type different text in the textbox. How do I do it in a textbox. When I load data into it. I just need to change its contents whenever I try to type a different word on the textbox which I use to search:

Here is the function in a vb.net module that I call from the form, if you can see something's wrong with my query, please tell also:

Public Function form5search_loadfrom_drug_table(ByVal drugname As String) As OdbcDataReader

        cmd.CommandText = "SELECT * FROM drug, drug_information, drug_inventory, drug_order WHERE drug.Drug_id=drug_information.Drug_id AND drug_inventory.Drug_id=drug_order.Drug_id AND drug.Drug_name LIKE '%" & drugname & "' "


        Return cmd.ExecuteReader


    End Function

And in the form I have this one, I load both the data into the datagridview and in the textboxes, thats why I called 2 methods/functions. This one is in the textbox_textchanged:

    Dim rdr As Odbc.OdbcDataReader

            rdr = con.form5search_loadfrom_drug_table(drugname)
            con.drugname = TextBox8.Text
            con.list()


            If rdr.HasRows = True Then
                rdr.Read()

                TextBox18.Text = rdr("Drug_name")
                TextBox1.Text = rdr("Drug_id")
                TextBox2.Text = rdr("Qty_Alert")
rdr.close()
end if

I have 2 problems though:

  1. What I see in the textboxes(using odbcreader) is just the first item in the mysql database. Perhaps there is something wrong with my query?
  2. The item that I see in the textboxes doesnt change.How do I change it?

Here's the screenshot, as you can see, the textboxes in the right side is not displaying what I'm typing, it just displays the first record in the table: alt text

Please help, thanks in advanced. By the way I'm using odbc driver to connect to mysql.