Create DataView and Bind to a Combobox

  • Thread starter Thread starter Rinso
  • Start date Start date
R

Rinso

Guest
Using Visual Studio Community 2015

Windows 8.1 on 64 bit machine

I have a simple Windows Forms project where I have created a Data Source "BagTimeDataSet" from a local Access database and saved the Connection string to the Project file. The dB contains a number of tables including the Suppliers table.

I wish to create a DataView from the dB Suppliers table using all the available records, Sort that view on Supplier Name and use that Dataview as the DataSource for a Comboxbox as per below;

Try
Dim viewSup As New DataView(BagTimeDataSet.Tables("Suppliers"), "SupId >= 1", "SupName ASC", DataViewRowState.ModifiedCurrent)

cboTabOrdersSupplier.DataSource = viewSup
cboTabOrdersSupplier.DisplayMember = "SupName"
cboTabOrdersSupplier.ValueMember = "SupId"

Catch ex As Exception
MessageBox.Show("Error : " & ex.Message, "Form Load", MessageBoxButtons.OK)
End Try

Trouble is I get 2 error messages;

Error BC30469 Reference to a non-shared member requires an object reference.
Error BC32016 Public ReadOnly Property Tables As DataTableCollection has no parameters and its return type cannot be indexed.

What am I doing wrong or missing?

TIA,

John

Continue reading...
 
Back
Top