Populating Windows Forms ComboBox from SQL Server using OLEDB and DataTable

For the database connection, and populating the DataTable see my post: Populating ASP.net DropDownList from SQL Server using OLEDB and DataTable

Hopefully you have now connected to your database and populated your DataTable. Now all we need to do is bind the DataTable to the ComboBox (in this case ComboBox1). This is just two lines or code:

comboBox1.DataSource = dtList;
comboBox1.DisplayMember = "USER_NAME"
Advertisements
This entry was posted in Programming and tagged , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s