Click to See Complete Forum and Search --> : Seek Method For Database


Operations
August 10th, 1999, 12:14 AM
I Want To Search A Row In A Database
What Should I Do ???

Lothar Haensler
August 10th, 1999, 02:40 AM
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).

Operations
August 10th, 1999, 04:00 AM
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

Gary Ng
August 10th, 1999, 08:27 PM
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

Praba S
August 10th, 1999, 08:49 PM
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