Results 1 to 5 of 5

Thread: [RESOLVED] Filter Datatable using Combo Box

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2006
    Posts
    13

    Resolved [RESOLVED] Filter Datatable using Combo Box

    Hello There. I am a bit stuck here I need URGENT HELP!!
    I have a combo box that I populated with "Publisher" column in form lord. I want to use the combo box to fliter the Datagrid. Here is my code. When I click Button to show the filtered results, nothing happens.
    VB Code:
    1. Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
    2. System.EventArgs) Handles MyBase.Load
    3.  
    4.         OleDbDataAdapter1.Fill(MyDataset11)
    5.         cbPublisher.DataSource = MyDataset11.Tables(0)
    6.         cbPublisher.DisplayMember = "Publisher"
    7.         cbPublisher.ValueMember = "Publisher"
    8.  
    9. End Sub
    10.  
    11. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
    12. System.EventArgs) Handles Button1.Click
    13.         Dim pub As String
    14.         pub = cbPublisher.Text
    15.         Dim dtBooks As New DataTable
    16.         Dim foundrows() As DataRow
    17.         dtBooks = MyDataset11.Tables(0)
    18.         Dim sqlString As String = "SELECT * FROM Book  WHERE pub = " & "'" & pub & "'" & ""
    19.         foundrows = dtBooks.Select("Publisher = 'sqlString'")
    20. End Sub
    Last edited by Hack; Jan 15th, 2007 at 08:03 AM. Reason: Added vbcode tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width