This example show how to link a table to a file in a FocPro DBC format.
FUNCTION Start()
LOCAL oEng AS DaoDbengine
LOCAL oDb AS DaoDatabase
LOCAL otd AS DaotableDef
LOCAL oRs AS DaoRecordSet
LOCAL oSrv AS DaoQuery
set color TO w+/b
cls
oEng := DaoDbengine{}
//-------------------------------------------------------------
// This part of the sample is only necessary once, to set up the link
// to the sample database
// First create a new database
Erase(PSZ("\VO2Jet\Test.mdb" ))
oDb := oEng:CreateDatabase("\VO2Jet\Test.mdb",;
DbLangGeneral,Dbversion30)
// Create a new tabledef
oTd := oDb:CreateTableDef("Category",NIL,NIL,NIL)
//
// Link the tabledef to the VFP sample database, using DBC
// Make sure you change this to point to the proper directory
//
oTd:Connect := "Foxpro DBC;DATABASE=D:\Vfp60\tasTrade.dbc"
// Tell it to open the Category.dbf
oTd:SourceTableName := "Category"
// Store the link to the FoxPro table in the MDB. In Access you'll
// see a fox icon before this table
oDb:TableDefs:Append(oTd)
// End of the part that needs to be run once
//-----------------------------------------------------------
// The rest of the sample can be run as often as you like
// without having to re-attach the file to the MDB
//
oDb := oEng:OpenDatabase("D:\VO2Jet\Test.mdb",NIL,NIL,NIL)
oRs := oDb:OpenRecordSet("Select * From Category",NIL,NIL,NIL)
oSrv := DaoQuery{oRs}
DO WHILE ! oSrv:Eof .and. oSrv:Recno < 21
? oSrv:FIELDGET(1), oSrv:FIELDGET(2),;
oSrv:FIELDGET(3),oSrv:FIELDGET(4)
oSrv:Skip()
ENDDO
IF ! oSrv:Eof
? "more.."
ENDIF
oSrv:GoBottom()
? "# of records", oSrv:LastRec
wait