Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display data from database to combo box in vb.net

Status
Not open for further replies.

desmondsaw

Programmer
Aug 12, 2003
5
0
0
MY
Pls Help!
i kenot display the data from database to combo box.. i did everything liao.. sql data adpater, sql connection and data set.. did the data source n display member.. data binding need to do which one?? but i try each of them liao... still kenot display data (id number)...
i miss do something izzit? oni can display the data grid one... combo box kenot.
 
Please help!!

i cannot display the data from database(sql server 2000) to combo box in vb.net. how? In data binding, which should i select?? text?? selected item?
 
Comboboxes which are bound to a table in a dataset need to have two properties set and a binding to work correctly.

In code:

cboDemo.DataSource = DsDataSet.Tables("Results")
cboDemo.DisplayMember = "Demo_ID"
cboDemo.DataBindings.Add("text", _
DsDataSet.Tables("Results"), "Demo_ID")

All have to be set to work correctly. These can be latebound as shown in your code,

or they can be bound at the property level of the control on the form. Open in design-view, click on the combo-box once, right-click and select the properties and set the individual controls there. The datasource, displaymember, and databindings properties under the databindings section will all have to be set.

Your choice, either will work if you are using datasets and tables.

Kateryn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top