Filling A Combo Box From A Database

kalypso

New member
Joined
Oct 19, 2004
Messages
4
Programming Experience
Beginner
I am having problems filling the combo box. Here is the code I have:

Dim conn = New Microsoft.Data.Odbc.OdbcConnection("DSN=MAC")

Dim ds As New Data.DataSet("Test2")

Dim dc As New Microsoft.Data.Odbc.OdbcCommand()

Dim da As New Microsoft.Data.Odbc.OdbcDataAdapter()

conn.Open()

dc.CommandText = "SELECT Item_No FROM IMINVLOC"

dc.Connection = conn

da.SelectCommand = dc

da.Fill(ds, "Item_No")

cboMain.DataSource = ds

dc.Connection.Close()

Here is what shows up in the box:

System.Data.DataViewManagerListItemTypeDescriptor

I'm not sure whats going wrong.
 
This did not seem to work. I was also looking into another thread on the forums here. It showed the code he used to fill a combo box. I tried that as well and it did not work. I am using pretty much the same code i have used to fill a data grid and it just does not seem to be working. Here is the code I have now:

Dim conn = New Microsoft.Data.Odbc.OdbcConnection("DSN=MAC")

Dim ds As New Data.DataSet("Test")

Dim dc As New Microsoft.Data.Odbc.OdbcCommand()

Dim da As New Microsoft.Data.Odbc.OdbcDataAdapter()

conn.Open()

dc.CommandText = "SELECT Item_No FROM IMINVLOC"

dc.Connection = conn

da.SelectCommand = dc

da.Fill(ds, "Item_No")

cboMain.DataSource = ds.Tables(0)

cboMain.DisplayMember = "Item_No"

DataGrid1.DataSource = ds.DefaultViewManager

dc.Connection.Close()

This does fill the data grid correctly but when it fill the combo box it put this in there:

System.Data.DataRowView

It puts that in there for every entry of the database. So I think it has the data but its not placing it into the combo box.
 
Back
Top