blah blah blah is here! blah blah » Close

up0down
link

Creating a contact book might sound silly, but this is my 1st project using a database.

I had posted details about this project of mine on csharpfriends but sadly that post was lost somewhere in shifting.

I wanted to know that if I want to assign a columnn values (mdb) to a combobox1 in my winform then how should I go about it?

I want my combobox to show all the values in a particular column (mdb).

VS 2005 express edition is not having support for excel files. :(

last answered 2 years ago

1 answers

up0down
link

well you should do a select statement that selects a single column from a table and execute the query by datatadapter. get the datatable and databind it to the combobox specifying the display member and value property.
you can do it by applying a code like that

DataSet ds=new DataSet();
System.Data.Odbc.OdbcDataAdapter adptr = new System.Data.Odbc.OdbcDataAdapter("select col1 from MyTable", connectionString);
adptr.Fill(ds);
DataTable tbl = ds.Tables[0];
this.comboBox1.DataSource = tbl;
this.comboBox1.DisplayMember = "col1";

gsvirdi
412

I'm having a prob here...... http://www.debugging.com/bug/23203#79963 In the meanwhile I'll implemente this code in a new project.

Feedback