How to set mySQL data source for combo box (C#) -


i beginner @ c# , having serious issues setting data source of combo box. want have happen follows: want combo box on c# windows forum populated string names in 1 column of table in mysql database.

the mysql table has following format:

river_id, river_name, ....... (other columns)  _____________________________________________ 1           river1 2           river2          3           river3 4           river4 5           river5 6           river6 

what want happen have combo box populated each river name. here attempt:

 string query = "select * sources";        mysqldataadapter riversourcesadapter = new mysqldataadapter(query,connectionstring);        dataset riverdataset = new dataset();        riversourcesadapter.fill(riverdataset);         combobox1.text = riverdataset.tables[0].rows[0][0].tostring(); 

i tried setting combo box datasource , datamember in designer instead, approach did not seem work either.

try this:

combobox1.datasource = riverdataset.tables[0]; combobox1.displaymember = "<column name>"; combobox1.valuemember = "<column name>"; 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -