CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2001
    Posts
    20

    searching for words

    i wish to know how to set up a simple but effecient control button that allows you to search for a word in a database. (even one with only 3 words would help!)nothing to advanced though since im only a begginer. anyones help would be greatly appriciated!


  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: searching for words

    This will search a field in an open (ado) recordset:

    private Sub Command1_Click()

    Dim cnn as new ADODB.Connection
    Dim rst as new ADODB.Recordset

    cnn.Provider = "Microsoft.Jet.OLEDB.4.0"
    cnn.open "c:\mydatabase.mdb"

    rst.open "mytable",cnn

    rst.Find "myfield like '*" & text1.text & "*'"

    If rst.eof then
    Msgbox "No records found"
    else
    Msgbox "Found a record!"
    end if

    End Sub




    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

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

Featured