Cannot bind to the property or column on the DataSource.

G

Guest

I'm trying to use the following code to do a very simple databind to a
combobox on a Windows Form. I keep getting the error shown in the code. Can
anyone tell me what I'm doing wrong?
Thanks.


Public Sub CreateDataSetsInitializeBindings()
Dim dsCompany As New DataSet

'create datasets
dsCompany = CreateDataSetCompany()

'initialize bindings
frmRoute.cboCompanyID.DisplayMember = "cmpCompanyID"
frmRoute.cboCompanyID.ValueMember = "cmpCompanyID"
frmRoute.cboCompanyID.DataSource = dsCompany
frmRoute.cboCompanyID.DataBindings.Add("SelectedValue", dsCompany,
"cmpCompanyID")
*** this line returns the error: Cannot bind to the property or column
cmpCompanyID on the DataSource.Parameter name: dataMember***


'clear objects
dsCompany = Nothing

End Sub

Public Function CreateDataSetCompany() As DataSet
Dim daCompany As New OleDb.OleDbDataAdapter()
Dim dsCompany As New DataSet

'Execute the SQL
daCompany = New OleDb.OleDbDataAdapter("SELECT * FROM Company", cnn)


'fill the dataset
daCompany.Fill(dsCompany, "Company")

'return the dataset
CreateDataSetCompany = dsCompany

'clear the objects
daCompany = Nothing
dsCompany = Nothing

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top