This example creates a new snapshot-type Recordset object and opens it, appending it to the Recordsets collection in the default database.
It then creates a Query object that uses this recordset and finds records in this query
It then finds a record and prints it.
FUNCTION Start
LOCAL dbeng AS DaoDBEngine
LOCAL db AS DaoDatabase
LOCAL rstTitles AS DaoRecordset
LOCAL oQuery AS DaoQuery
Set color TO w+/b
cls
// Open the database.
dbEng := DaoDbEngine{}
db := dbEng:OpenDatabase("\VO2jet\Northwind.mdb",NIL,NIL,NIL)
// Open a recordset on Titles table.
rstTitles := db:OpenRecordset("Titles", dbOpenSnapshot,NIL,NIL)
oQuery := DaoQuery{rstTitles}
IF oQuery:LastRec > 0
? "# Title"
IF oQuery:FindFirst("Title Like '*Computer*'") // Any title on computers
DO WHILE TRUE
? NTrim(oQuery:Recno), oQuery:FIELDGET(#Title)
IF .not. oQuery:FindNext("Title Like '*Computer*'")
EXIT
ENDIF
ENDDO
ENDIF
?
? "And now in reversed order"
?
? "# Title"
IF oQuery:FindLast("Title Like '*Computer*'") // Any title on computers
DO WHILE TRUE
? NTrim(oQuery:Recno), oQuery:FIELDGET(#Title)
IF .Not. oQuery:FindPrevious("Title Like '*Computer*'")
EXIT
ENDIF
ENDDO
ENDIF
Wait
? "Now set a filter and use that to select the records"
oQuery:Where("Title Like '*Computer*'")
DO WHILE ! oQuery:Eof
? NTrim(oQuery:Recno), oQuery:FIELDGET(#Title)
oQuery:Skip(1)
ENDDO
wait
? "Now sort the data ASCENDING on title and display the titles"
oQuery:orderBy("Title")
DO WHILE ! oQuery:Eof
? NTrim(oQuery:Recno), oQuery:FIELDGET(#Title)
oQuery:Skip(1)
ENDDO
wait
? "Now remove the filter, resort DESCENDING on title and display the titles"
oQuery:WhereOrderBy("", "Title desc")
DO WHILE ! oQuery:Eof
? NTrim(oQuery:Recno), oQuery:FIELDGET(#Title)
oQuery:Skip(1)
ENDDO
ELSE
? "No such title"
ENDIF
db:Close()
wait