Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...