I have an application that loads cars data from sql server database as follows.
sql = " select car.*, (model + ' -- ' + plateNo) as selectCar from car"
daAdapter = New SqlDataAdapter(sql, sqlConn)
daAdapter.Fill(dsDataset, "car")
So data would look like the following:
Then instead of loading distinct values of brand from database I have created one datatable to get the distinct values of the brand. And then add it to the dataset as follows:
tblBrand = New DataTabl
tblBrand = dsDataset.Tables("car").DefaultView.ToTable(True, "brand")
tblBrand.TableName = "brand"
dsDataset.Tables.Add(tblBrand)
Actually I use this brand table to display the filter options in the brand combobx without any problem.
What I need is that when I press the add button I go to an other form and I want to use this brand options in the other form. So when I click the add button I have the following code:
Dim newCar As New frmCar(dsDataset)
carMode = "new"
newCar.ShowDialog()
And I created a constructor in the frmCar form as follows:
Sub New(ByVal dsOptions)
InitializeComponent()
Try
cmbBrand.DataSource = dsOptions.table("brand")
cmbBrand.DisplayMember = "brand"
cmbBrand.ValueMember = "brand"
Catch ex As Exception
MsgBox(Err.Description)
End Try
End Sub
But the following error pops up:
Public member 'table' on type 'DataSet' not found.
What is wrong with my code?