I have an ADO.Net app that uses an ODBC connection to a remote database (so I don't need to hardcode in the servername and password). I have one form that uses a DataGridView to show data from a TableView. I need to filter this data using the selected item in a ComboBox. I'm using the SelectedIndexChange method. I can build everything down to the dataset but I cant get the DataGrid view to show any of the selected data. What am I doing wrong?
Dim Con As New Odbc.OdbcConnection
Con.ConnectionString = My.Settings.ODBCConnectionString
Dim Com As New Odbc.OdbcCommand
Com.Connection = Con
Com.CommandText = "Select ProductName, CategoryName, Barcode, UnitsInStock, Par " & _
"From vProduct " & _
"Where ProductName like '" & ComboBox1.SelectedValue & "' and Discontinued = 0 " & _
"Order By ProductName"
Con.Open()
Dim da As New Odbc.OdbcDataAdapter
Dim ds As New DataSet
da.SelectCommand = Com
da.Fill(ds, "Product")
VProductDataGridView.DataSource = ds
VProductDataGridView.DataMember = "Product"
Thanks
VProductDataGridView.DataS
Then to filter it:
Dim view As DataView = Me.DataGridView1.DataSourc
view.RowFilter = "ColumnName='" & ComboBox.Text & "'"
That's it.
To remove the filter:
Dim view As DataView = Me.DataGridView1.DataSourc
view.RowFilter = ""