7
Contributors
8
Replies
23
Views
5 Years
Discussion Span
Last Post by Hamid_2
0

Hmm, Tellalca? What an answer is that?? If you want to comment threads like that, you better do NOT write at all. Otherwise you will be penelized, ok?
Sorry for inconveniances.

Ok, back to the thread`s topic, you can bind data from dataTable, which gets filled from database like this:

DataTable table = new DataTable();
using(SqlConnection sqlConn = new SqlConnection("connString")) //use your conn. string here
{
   using(SqlDataAdapter da = new SqlDataAdapter(@"SELECT Id, Name FROM Person", sqlConn))
       da.Fill(table);
}
comboBox1.DataSource = new BindingSource(table, null);
comboBox1.DisplayMember = "Name"; //colum you want to show in comboBox
comboBox1.ValueMember = "Id"; //column you want to use in the background (not necessary)!

This is about it. Oh yee, rename the sql select query, and use your own names (table and field names) from database.

Hope it helps,

0

Hie Mitja Bonca
I copied your code,but it din't show any items of columns in the combo box.
Can you direct me where I went wrong?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.