Binding a combo box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I configured a data adapter and generated a dataset and wrote the code to
fill the dataset with data coming from an SQL database table when my form
loads. I also changed the DataSource of a combo box to point to the
dataset.tablename and changed the DisplayMemebr to point at a column. After
the form loads nothing is populated in the combo box? Is there something I'm
missing. Please help
 
Hi,

Here is an example.

Dim strConn As String

Dim strSQL As String

Dim ds As New DataSet

Dim da As OleDbDataAdapter

Dim conn As OleDbConnection

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 = "Description"



Ken

--------------------------

I configured a data adapter and generated a dataset and wrote the code to
fill the dataset with data coming from an SQL database table when my form
loads. I also changed the DataSource of a combo box to point to the
dataset.tablename and changed the DisplayMemebr to point at a column. After
the form loads nothing is populated in the combo box? Is there something I'm
missing. Please help
 
TS,

Show a little piece of code, (first without the designer part).
(And please first pasted in a notebook and copied back to make it readable)

(I assume that you bind in the desiger and that you told in that wich
*datatable*, often is the wrong point taken to do that, so you can check
that first)

Cor
 
Thanks for your reply. I tried the code you sent me and it generated the
following error message: "Unhandled Exception:
System.Data.OleDb.OleDbException: Multiple-step OLE DB operation generated
errors. Check each OLE DB status value, if available. No work was done.

Here is the code:

Dim strConn As String

Dim strSQL As String

Dim SscIntake1 As New DataSet()

Dim da As OleDb.OleDbDataAdapter

Dim conn As OleDb.OleDbConnection

strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"
strConn &= "Data Source = Persist Security Info=true;Integrated
Security=false;User ID=sa;Password=xxx;database=SSC;server=zzz;"

conn = New OleDb.OleDbConnection(strConn)

da = New OleDb.OleDbDataAdapter("Select * From qmf_cint", conn)

da.Fill(SscIntake1, "qmf_cint")

ComboBox1.DataSource = SscIntake1.Tables("qmf_cint")

ComboBox1.DisplayMember = "Last_Name"
 
Back
Top