Results 1 to 4 of 4

Thread: Searching DataGrids

  1. #1
    Registered+
    Join Date
    Aug 2005
    Location
    Liverpool/Brum Uni
    Posts
    18
    Thanks
    0
    Thanked
    0 times in 0 posts

    Searching DataGrids

    Hi,

    I’m trying to implement a search function within my vb application to search a datagridview.



    Basically I need to search the datagrid, using any key word, e.g. if "L" is typed, all entries with L in either postcode, Lname or Fname is found and displayed in the datagrid.

    I’m pretty sure there’s a simple solution, but I’ve never worked with data grids before!


    Cheers for any help or advice you can give.

    (Incase its important i'm using Visual Studio 05)

  2. #2
    Seething Cauldron of Hatred TheAnimus's Avatar
    Join Date
    Aug 2005
    Posts
    17,164
    Thanks
    803
    Thanked
    2,152 times in 1,408 posts
    what is the view bound too?

    If its a dataset its very easy to use the ADO like query langauge via SELECT
    throw new ArgumentException (String, String, Exception)

  3. #3
    Registered+
    Join Date
    Aug 2005
    Location
    Liverpool/Brum Uni
    Posts
    18
    Thanks
    0
    Thanked
    0 times in 0 posts
    Sorry should of replied, solved it in the end. just used a stored procedure in the database, calling it from the search.
    Code:
    Dim CNN As OleDb.OleDbConnection = New OleDb.OleDbConnection
            CNN.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Gadgets.mdb"
            CNN.Open()
            Dim CMD As OleDb.OleDbCommand = New OleDb.OleDbCommand
            CMD.CommandText = "QrySearch"
            CMD.CommandType = CommandType.StoredProcedure
            CMD.Connection = CNN
    
            CMD.Parameters.AddWithValue("@Key Word", txtSearch.Text)
    
            Dim da As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter
            Dim dsTest As DataSet = New DataSet
            da.SelectCommand = CMD
    
            da.Fill(dsTest, "tblcustomers")
    
            DGVcustomers.DataSource = dsTest.Tables("tblcustomers")
          
    
            CMD.Dispose()
            CNN.Dispose()
            CNN.Close()

  4. #4
    Seething Cauldron of Hatred TheAnimus's Avatar
    Join Date
    Aug 2005
    Posts
    17,164
    Thanks
    803
    Thanked
    2,152 times in 1,408 posts
    your using a dataset already, which is been bound.

    So you could just go

    dsTest["tblCustomers"].Select("WHERE name = \"bob\"");

    but thats not quite seamless enough, so in .net we have full databinding via the DataView

    http://msdn2.microsoft.com/en-us/lib...w_members.aspx

    check the example on:
    http://msdn2.microsoft.com/en-us/lib...rowfilter.aspx

    basically you just set DataSource to be the created DataView, and you have full control, with no calls needed to the database.
    throw new ArgumentException (String, String, Exception)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [ SEARCHING ] - new GFX card - please advise
    By {dTa}aRny in forum Retail Therapy and Bargains
    Replies: 9
    Last Post: 25-07-2005, 03:02 AM
  2. Searching for 6800GT
    By GarethG in forum Graphics Cards
    Replies: 0
    Last Post: 24-12-2004, 05:37 PM
  3. Searching
    By Howard in forum Software
    Replies: 2
    Last Post: 04-01-2004, 10:30 AM
  4. Searching
    By Lexeus in forum HEXUS Suggestions
    Replies: 5
    Last Post: 20-11-2003, 10:56 PM
  5. Faster Tech net searching....
    By Jiff Lemon in forum Software
    Replies: 1
    Last Post: 22-10-2003, 03:53 PM

Posting Permissions

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