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"

Be First to Comment

Leave a Reply