Click here to Skip to main content
15,907,493 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi all
i have a comboBox with 4 value:A,B,C,D
and i have table in DB.One of table fields is for record for "typeofUser" example A.
Type of field in DB is "Text".
Now:
SQL
select * from table where ID=txtID.text 
to read form DB and put record details to controls in a form.
so i want to see value of "typeofUser" example A from DB in the comboBox.(ComboBox1.selectedIndex=0)
how can i do that?
Best regards
Posted
Comments
Herman<T>.Instance 15-Feb-12 4:32am    
what is your exact problem? connecting to the database? retrieving the data using a sqlcommand?
FM7 15-Feb-12 5:13am    
NO.Both are ok.but reading text from one field of table and binding it to the combobox.
can you help?
FM7 15-Feb-12 5:10am    
No answers!!?
Herman<T>.Instance 15-Feb-12 6:02am    
You want to add a New ListItem() ? to the combobox
Jαved 15-Feb-12 6:10am    
you want to show records of type (selected from combobox) in second combobox right?

look here[^]
 
Share this answer
 
Hi,
On the "typeofUser" comboBox_SelectedIndex_Changed() event write the code to retrieve records, in your case -
select * from table where ID=txtID.text 

and the bind to the control with DataSet.


Thanks,
Javed
 
Share this answer
 
If you bind the data set returned by that query to the combo, and set the DataMember property to be the column which is A, B, C or D, then it should already do what you want.
 
Share this answer
 

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