Please help, how do I really use data reader in vb.net. I'm using odbc to connect mysql and vb.net.
Function I declared on a module:
Public Function form2search(ByVal drugname As String) As OdbcDataReader
cmd.CommandText = "SELECT * FROM drug WHERE Drug_name LIKE'%" & drugname & "' "
Return cmd.ExecuteReader
End Function
text_changed event:
con.drugname=textBoxdrugname.text
Dim rdr As Odbc.OdbcDataReader
rdr = con.form2search(drugname)
if rdr.hasrows=true then
rdr.read()
TextBoxdrugname.Text = rdr("Drug_name").ToString
TextBoxdrugcode.Text = rdr("Drug_code").ToString
drugtype.Text = rdr("Drug_type").ToString
end if
I see a result, but it only loads the first item on the database. I've put this code in the text_changed event. What's the proper way of doing this? And what's wrong with the 2nd code, why is it only loading the first data
As you can see the con is the module where I declared the function. Then I created an object of it in the form.