Click here to Skip to main content
16,004,574 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hai everybody,
i have one table named Student with columns Rollno,Name,FatherName .
one form contain comboBox . i have to add total RollNos to that combobox .
help me...
Posted
Comments
Sandeep Mewara 29-Jul-10 8:08am    
Reason for my vote of 1
Height of Spoon Feeding expected! Answer was as per question and yet downvoting the answer though it was not the mistake.

1 solution

may be you are asking this

SqlConnection con = new SqlConnection("<connectionstring>");
SqlDataAdapter ad;
DataTable dt = new DataTable();
ad = new SqlDataAdapter("select Rollno from Student",con);
ad.Fill(dt);
comboBox1.DataSource=dt;
comboBox1.DisplayMember="Rollno";//column name of DataBase Table
comboBox1.ValueMember="Rollno";//column name of Database Table


</connectionstring>
 
Share this answer
 
Comments
satyagrahi_2010 29-Jul-10 7:23am    
Getting Error at Rollno doesnot exist in the current context.
Sandeep Mewara 29-Jul-10 8:07am    
If that is the error, it's not because of your mistake. He answered correctly. You are an idiot to just copy-paste the whole thing, and when it gives error you vote him down!

You need to change the query to whatever columns you want to fetch data. Run the query first, see the data and then use the same query.
Sandeep Mewara 29-Jul-10 8:09am    
Removed the 2-vote given by OP as it was not your mistake.
koool.kabeer 29-Jul-10 8:17am    
"RollNo" is the name of the DataBase Column ....i think you have posted the Structure of DataBase table of "Student" as Rollno,Name and FatherName as three columns, "Rollno" is one of those columns
koool.kabeer 29-Jul-10 8:17am    
thanx sandeep....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900