Navigation:  Samples >

Table Sample

Previous pageReturn to chapter overviewNext page

This example opens a table-type Recordset and creates a Table object with this recordset.

It then selects an index for the Recordset. By setting an index, the Microsoft Jet database engine returns records in the order specified by the index. Without an index, table-type Recordset objects return records from the database table in no particular order.

It finally lists some of the values in the order of the index

 

FUNCTION Start

LOCAL dbeng                AS DaoDBEngine

LOCAL db                AS DaoDatabase

LOCAL rstCust        AS DaoRecordset

LOCAL rstCust1        AS DaoRecordset

LOCAL oTable        AS Daotable

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.

rstCust := db:OpenRecordset("Customers", dbOpenTable,NIL,NIL)

oTable        := DaoTable{rstCust}

oTable:Index := "PrimaryKey"

? "Index", oTable:Index

? "Seek >= WAL", oTable:Seek(">=","WAL")

wait

DO WHILE ! oTable:Eof

 ? oTable:FIELDGET(1), oTable:FIELDGET(2), oTable:FIELDGET(3)

 oTable:SKip(1)

ENDDO

wait

oTable:close()

db:Close()