CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 1999
    Posts
    5

    Seek Method For Database

    I Want To Search A Row In A Database
    What Should I Do ???


  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Seek Method For Database

    to search for "charlie" in an address table:
    SELECT * FROM ADDRESS WHERE NAME = 'charlie'

    There are many more ways to do that depending on the database backend and the database interface (DAO/ADO).


  3. #3
    Join Date
    Aug 1999
    Posts
    5

    Re: Rephrase - Seek Method For Database

    ok so the db im using is access
    i have a table called "Phones"
    there i have 3 columns "Name" , "Address" , "Phone"

    how do i search for a name in it

    please write me the code

    thnx


  4. #4
    Join Date
    Jul 1999
    Location
    Singapore
    Posts
    42

    Re: Rephrase - Seek Method For Database

    Hi,

    First, add a "Data Control" into your form. Then, do as below:

    Dim dbs as Database
    dim recordset as Recordset
    dim ssql as String

    ssql="SELECT * FROM Phones WHERE Name=' " & Charlie & "' "

    Set dbs=Opendatabase ("C:\xxx.mdb")
    Set recordset=dbs.OpenRecordSet(ssql,dbOpenDynaset)

    With recordset
    If Not .EOF and Not .BOF Then
    .MoveFirst
    Do
    strAddress= !Address
    strPhone= !Phone
    Loop Until .EOF

    .Close
    End With
    dbs.Close


    With this, the address and the phone for the particular Name will be hold by strAddress and strPhone respectively.

    Gary



  5. #5
    Join Date
    Jul 1999
    Posts
    20

    Re: Rephrase - Seek Method For Database

    Dim db as database
    dim rs as Recordset

    set db = opendatabase("c:\xx.mdb")
    set rs = db.openrecordset("Select * from master",dbopenSnapshot)

    ' to select the first match
    rs.findfirst "name = 'charlie'"
    ' check for rs.nomatch


    ' to select the next match
    rs.findnext

    rgds
    Praba


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