Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 25, 2012 10:05 PM by aarsh
Nov 20, 2012 04:53 AM|LINK
I have a question about combo box. How can I use the column header of my database for the selection in combo box.
I am using c# and sql for database
Nov 20, 2012 04:59 AM|LINK
select column_name from information_schema.columns where table_name='tab1'
You can create a stored procedure and pass table name as a parameter to it. Use the parameter instead of hardcoded value 'tab1'.
Nov 25, 2012 10:05 PM|LINK
Below is the code which might help you. I am using MySQLDatabase, but the code shoudl work regardless of what DBServer we are using. So replace all my MySQL operations with what you're using as usual. After you get data in datatable, try to follow the scenario
Assumming ComboBox 1 enlists all the colums ( "headers" ) of the database and ComboBox 2 needs to populate all the records of that column :
On from load
foreach (DataColumn c in dtCustomers.Columns)
and on the comboBox1_SelectedIndexChanged event ...
foreach (DataRow dr in dt.Rows)
I've created a dedicated sample Windows forms application for this example and uploaded to my code library. You are free to download it from
http://sdrv.ms/S5KzC5 | File name : ComboBoxMySQLDatabaseConnectivityDemo.zip
Please mark this post as an answer if it solves your problem - Thanks much.