I am a beginner at C# and am having some serious issues setting the data source of a combo box. What I want to have happen is as follows: I want the combo box on my C# windows forum to be populated with the string names in just one column of a table in my mySQL database.
The mySQL table has the following format:
river_id, river_name, ....... (other columns)
_____________________________________________
1 river1
2 river2
3 river3
4 river4
5 river5
6 river6
What I want to happen is have the combo box be populated with each river name. Here is my attempt:
string query = "SELECT * FROM sources";
MySqlDataAdapter riverSourcesAdapter = new MySqlDataAdapter(query,connectionString);
DataSet riverDataSet = new DataSet();
riverSourcesAdapter.Fill(riverDataSet);
comboBox1.Text = riverDataSet.Tables[0].Rows[0][0].ToString();
I also tried setting the combo box datasource and datamember in the designer instead, but that approach did not seem to work either.