I Want To Search A Row In A Database
What Should I Do ???
Printable View
I Want To Search A Row In A Database
What Should I Do ???
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).
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
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
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