Cannot bind to the property or column on the DataSource.

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
Back
Top