Navigation:  Samples >

DbEngine sample

Previous pageReturn to chapter overviewNext page

This example enumerates the collections of the DBEngine object. See the methods and properties of DBEngine for additional examples.

 

FUNCTION Start

LOCAL oEng        AS DaodBEngine

LOCAL oWs        AS DaoWorkspace

LOCAL i                AS LONG

set color TO w+/B

cls

// If you want to use DAO 3.60, and the Jet Eninge 4.0

// Uncomment the next line

DaoEnableVersion36(TRUE)

oEng        := DaoDbEngine{}

// Enumerate all workspaces.

 

? "Workspaces: Name, UserName"

FOR i = 1 TO oEng:Workspaces:count

 oWs := oEng:Workspaces:[item,i]

 ? oWs:name, oWs:Username, oWs:Type

NEXT

// Default Collection of DbEngine is DaoWorkspaces

? oEng[1]:Name, oEng[1]:UserName

// display built-in properties.

? "DBEngine:Version     : ", oEng:Version

? "DBEngine:LoginTimeout:" , oEng:LoginTimeout

 

wait

 

Sample with private Engines:

 

FUNCTION Start()

 LOCAL oEng1, oEng2 AS DaoDbEngine

 LOCAL oDb AS DaoDatabase

 ? "Now open two engines that are NOT private"

 ? "and open database in first one"

 oEng1 := DaoDbEngine{,FALSE}

 oEng2 := DaoDbEngine{,FALSE}

 oDb := oEng1:OpenDatabase("D:\Vo2Jet\northwind.mdb",NIL,NIL,NIL)

 ? "# of open databases in Engine 1", oEng1:Workspaces[1]:Databases:Count

 ? "# of open databases in Engine 2", oEng2:Workspaces[1]:Databases:Count

 

 oENg1:Destroy()

 oEng2:Destroy()

 

 ? "====================================="

 ? "Now open two engines that are PRIVATE"

 ? "and open database in first one"

 oEng1 := DaoDbEngine{,TRUE}

 oEng2 := DaoDbEngine{,TRUE}

 oDb := oEng1:OpenDatabase("D:\Vo2Jet\northwind.mdb",NIL,NIL,NIL)

 ? "# of open databases in Engine 1", oEng1:Workspaces[1]:Databases:Count

 ? "# of open databases in Engine 2", oEng2:Workspaces[1]:Databases:Count

 

 WAIT