I have all the days of the week in a combobox, yet when selecting a day all the days are shown in my data grid... How can I use the one selected value from the combobox to searc
You can Simply make a filter in your datagridview using following code
Dim column As String = 'Your weekday column Name in Datagridview
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim rows = ds.Tables(0).Select("Convert(" & column & ", 'System.String') LIKE '*" + ComboBox1.SelectedItem + "*'")
Try
DGTimeTable.DataSource = rows.CopyToDataTable
Catch ex As Exception
End Try
End Sub
you are passing cbDay as a string, try changing this line
Dim SqlQuery As String = "SELECT Time, Activity, Equipment FROM TimeTable WHERE Day = cbDay"
to something like this
Dim SqlQuery As String = String.Format("SELECT Time, Activity, Equipment FROM TimeTable WHERE Day = {0}", cbDay.Text)