Results 1 to 7 of 7

Thread: Database Search Please Help

  1. #1

    Thread Starter
    Addicted Member Rally2000's Avatar
    Join Date
    Dec 2003
    Location
    Central USA
    Posts
    134

    Question Database Search Please Help

    Sorry about posting this again but my Question from a while back was not answered yet so I thought I’ll ask again.
    I have a simple front End for an Access database and would like to include a Search option. I have looked in my books and did not find anything there. (well it’s probably there I just don’t see it) Also I am a beginner and am looking for some simple code I don’t need noting extravagant.
    Could someone please help?

  2. #2

    Thread Starter
    Addicted Member Rally2000's Avatar
    Join Date
    Dec 2003
    Location
    Central USA
    Posts
    134
    Anyone know??

  3. #3
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Reading, UK
    Posts
    870
    you need to decide which fields you are going to let people search on, add a text box for each one, and then build the SQL statement when they click the search button. Do this by checking to see if they have entered anything in each text box that they are allowed to search on.

    It will invlove a lot of 'if' statements so be careful not to allow people to search on too many things.
    www.vb-tech.com
    .Net Freelance Development
    http://weblog.vb-tech.com/nick
    My blog

  4. #4

    Thread Starter
    Addicted Member Rally2000's Avatar
    Join Date
    Dec 2003
    Location
    Central USA
    Posts
    134
    This all sounds good but it sill don’t tell me how to implement the statements in my program. I would appreciate some guidance with a small code sample if at all possible, also, it is an ado database and I would like to be able to search only 2 of the fields but I don’t care if I could search all of them.
    Thanks much!!

  5. #5
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Dude thats easy. If you know how to write a query, then writing a search function should be no problem. This is what you need to do. Get the text from the text boxes for the field you want to search on then build the sql query. Execute that query against your DB table then populate your datagrid with the results.

  6. #6

    Thread Starter
    Addicted Member Rally2000's Avatar
    Join Date
    Dec 2003
    Location
    Central USA
    Posts
    134
    That is what I'm trying to learn.
    Id did not seem to difficult to build the database but when it came time to code the search I sort of hit a wall. If you look at the first post you will see where I’m saying that I’m new to programming. That is the reason I was asking for an example.
    I’m looking in my book but I do not see “Sorry for asking Stupid Questions” just trying to learn.
    I don’t do this full time like most people here, nor will I ever be good at this but I would like to learn how to create some small aps.
    Thanks to anyone that is willing to lend a hand, the world needs more people that are willing to help each other.

  7. #7

    Thread Starter
    Addicted Member Rally2000's Avatar
    Join Date
    Dec 2003
    Location
    Central USA
    Posts
    134
    This is what I "was thinking" the book said to do but it don't work?
    Code:
    If txtSCaseID.Text = "" Then Exit Sub Else 
            Resume
    
            strSearch = Trim(txtSCaseID.Text)
            OleDbDataAdapter1.SelectCommand.Parameters("Case ID").Value = strSearch
            OleDbDataAdapter1.Fill(DataSet11.Bankruptcy)
            DataSet11.AcceptChanges()
    
        End Sub

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