dbDAO Syntax

The following dbDAO code (with lengthy argument names and macro declarations removed) is syntactically similar to corresponding Visual Basic code.

dbDAO Visual Basic
CdbDBEngine		e;
CdbDatabase		d;
CdbRecordset		r;

d = e.OpenDatabase("Northwind.mdb");
r = d.OpenRecordset("Employees");
Dim dbs As Database
Dim rst As Recordset

Set dbs = OpenDatabase("Northwind.mdb")
Set rst = dbs.OpenRecordset("Employees")

There is one notable difference between dbDAO and Visual Basic. Unlike Visual Basic, dbDAO requires declaring a variable of class CdbDBEngine to be the first DAO call. This declaration calls the constructor function that creates the CdbDBEngine object. For more information, see “Initializing CdbDBEngine” later in this chapter.

See Also For more information about language differences, see the DAO SDK Help topics for C++, and the corresponding Visual Basic examples.

Besides language differences (for example, how variables are typed), there are some other differences in the way DAO properties, methods, and collections appear in code in dbDAO and Visual Basic. They are described in more detail in the following sections.