Almost correct, but you need to load data using DataReader.
Then, casting the DataTable to a DataSource Combo
Using connection As SqlConnection = New SqlConnection(ConnectionString) connection.Open() Using comm As SqlCommand = New SqlCommand(sqlquery, connection) Dim rs As SqlDataReader = comm.ExecuteReader Dim dt As DataTable = New DataTable dt.Load(rs) ' as an example set the ValueMember and DisplayMember' ' to two columns of the returned table' cmboxDatabaseName.ValueMember = "IDCustomer" cmboxDatabaseName.DisplayMember = "Name" cmboxDatabaseName.DataSource = dt End Using 'comm End Using 'conn
You can also set the combobox ValueMember property to the column name that you will use as a key for future processing, and the DisplayMember property to the column name that you want to display as text of your choice
Steve source share