mysql workbench - selected ID from table 1 to retrieve username from similar id in table 2 vb.net -


i've have 2 tables. recipes , foodcategories

recipes table:

id|     recipe name     |description|foodcategoryid|  --+---------------------+-----------+--------------|  1 | chicken soup        | ********* |      3       | 2 | sunrise surprise    | ********* |      1       | 3 | toated ham & cheese | ********* |      5       | 

foodcategories table:

foodcategoryid | foodcategory | ---------------+--------------|              1 | breakfast    |              2 | lunch        |              3 | dinner       |              4 | snack        |              5 | brunch       | 

the recipes table have displaying on windows form in datagridview1. once user clicks on row pops new form several text boxes filled data row clicked on. textbox have trouble foodcategory textbox named categorytxtbox. displays foodcategoryid foodcategories table , need display foodcategory.

the code have sofar is:

private sub datagridview1_cellclick(byval sender object, byval e datagridviewcelleventargs) handles datagridview1.cellclick     dim conn new mysqlconnection     dim cmd new mysqlcommand     conn.connectionstring = "server=; user id=; password=; database=;"     cmd.connection = conn     conn.open()         form2.catagorytxtbox.text = datagridview1.selectedcells(5).value.tostring end sub 

but, displays foodcategoryid.

please take note don't know how program, started yesterday , i'm trying done myself. unfortunately can't find answers regarding that's why i'm turning forum. if has suggestions please.

i solved question after 100 tries following code:

dim reader mysqldatareader     try         con.open()         dim query string         query = "select * foodcategories foodcategoryid = '" & datagridview1.selectedcells(5).value.tostring & "'"         cmd = new mysqlcommand(query, con)         reader = cmd.executereader         while reader.read             dim sname string             sname = reader.getstring("foodcategory")             recipecontent.catagory.text = sname         end while         con.close()              con.dispose()     end try 

please if can tell me if correct way of doing it?


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -