Complex Bind Combo Box VB.Net

  • Thread starter Thread starter Travis
  • Start date Start date
T

Travis

I am new to VB.NET and I am trying to use a complex bind for a combo
box. I have successfully created a data set, I have set my DataSource
value to the dataset and the DisplayMember value to the field in the
dataset I wish to utilize. When I run the form the combo box has no
information. What am I doing wrong?

Thanks!!
Travis
 
Hi,

You should use a datasource of dataset.table.

Here is an example Assumes you import system.data.oledb

Dim conn As OleDbConnection

Dim strConn As String

Dim strSQL As String

Dim da As OleDbDataAdapter

strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"

strConn += "Data Source = Northwind.mdb;"

conn = New OleDbConnection(strConn)

da = New OleDbDataAdapter("Select * From Categories", conn)

da.Fill(ds, "Categories")

ComboBox1.DataSource = ds.Tables("Categories")

ComboBox1.DisplayMember = "CategoryName"



Ken
 
Hi Travis,

You have to set the datasource to a dataset table when you use a dataset not
the dataset itself.
something as
\\\
combobox1.datasource = dataset.tables("mytable")
///

I hope this helps,

Cor
 
Back
Top