Using VS2005 with C#
I want to fill the combobox by using the table value.
Code
OdbcConnection con = new OdbcConnection();
OdbcCommand cmd;
con.ConnectionString = "";
con.Open();
cmd = new OdbcCommand("Select no from table", con);
ada = new OdbcDataAdapter(cmd);
ds = new DataSet();
ada.Fill(ds);
combobox1.Items.Add(ds);
But no values was loading in the combobox, what wrong with my above mentioned code.
can any provide a solution for the probelm….
You do have something in your real connection string, right?
You’re loading your data into a DataSet – that’s a collection of tables and relations. How should the combobox know what table’s data to display?? If the
DataSethas multiple tables in it, you would have to additionally define which one of those to use. If theDataSethas only one table inside, then it’s a waste of resources to use aDataSetin the first place.If you only have a single set of data, use a
DataTableinstead: