I have a datagrid that loads a dataset when the form is loaded. It displays all of the rows just fine.
I am trying to filter rows using a Combo Box List. The Msgbox displays the correct string value selected from the Combo Box.
When the dataset is filled with the filtered query in the code below, no rows are displayed in the datagrid.
Can anyone help me with this problem.
Thanks
Here is my code:
Private Sub CboBxLocations_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CboBxLocations.SelectedIndexChanged
If CboBxLocations.Text = "All Locations" Then
strSelectLocation = ""
Else
strSelectLocation = CboBxLocations.Text
End If
MsgBox("The Location selected is " & strSelectLocation, MsgBoxStyle.Information)
Dim objDataCommand As New OleDb.OleDbCommand
LocationDataView()
Dim strsql As String = "Select * from Pokerstats WHERE (Location = & strSelectLocation)" & _
"AND (Game_played = & strSelectGame) ORDER BY ID"
Dim objDataAdapter As New OleDb.OleDbDataAdapter(strsql, DBConnect)
Dim objDataset As New DataSet
Try
DBConnect.ConnectionString = Me.OleDbConnection1.ConnectionString
DBConnect.Open()
objDataAdapter.Fill(objDataset, "PokerStats")
DBConnect.Close()
DBConnect.Dispose()
Catch ex As Exception
End Try
Simply bind the data to our dataset and set the displayed table
to the Pokerstats datatable
Me.grdPokerStats.DataSource = objDataset
Me.grdPokerStats.DataMember = "PokerStats"
End Sub
I am trying to filter rows using a Combo Box List. The Msgbox displays the correct string value selected from the Combo Box.
When the dataset is filled with the filtered query in the code below, no rows are displayed in the datagrid.
Can anyone help me with this problem.
Thanks
Here is my code:
Private Sub CboBxLocations_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CboBxLocations.SelectedIndexChanged
If CboBxLocations.Text = "All Locations" Then
strSelectLocation = ""
Else
strSelectLocation = CboBxLocations.Text
End If
MsgBox("The Location selected is " & strSelectLocation, MsgBoxStyle.Information)
Dim objDataCommand As New OleDb.OleDbCommand
LocationDataView()
Dim strsql As String = "Select * from Pokerstats WHERE (Location = & strSelectLocation)" & _
"AND (Game_played = & strSelectGame) ORDER BY ID"
Dim objDataAdapter As New OleDb.OleDbDataAdapter(strsql, DBConnect)
Dim objDataset As New DataSet
Try
DBConnect.ConnectionString = Me.OleDbConnection1.ConnectionString
DBConnect.Open()
objDataAdapter.Fill(objDataset, "PokerStats")
DBConnect.Close()
DBConnect.Dispose()
Catch ex As Exception
End Try
Simply bind the data to our dataset and set the displayed table
to the Pokerstats datatable
Me.grdPokerStats.DataSource = objDataset
Me.grdPokerStats.DataMember = "PokerStats"
End Sub