for window application
I want to fill data in combo box from database using asp.net c# and sql server

OK, good luck with that !

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,

Does it work?
it should ;)

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 is good method for fetch record from database

Thanx buddy..It works. Thanks a lot once again.

how i can bind a lable to combobox value

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.