DAO Topics
<<Back
Next>>


DAO Overview


The DATA ACCESS MODEL is a set of DLLs that forms the core of the Jet Database Engine. DAO supports two different types of database environments. Using the Microsoft Jet Database Engine, DAO is optimized for accessing local Index Sequential Access Method (ISAM) databases such dBase, Paradox, Foxpro, and others. Using OBDCDirect, DAO is optimized for ODBC databases, with minimal overhead. The DAO user interface, which is developed using Visual Basic, contains all the necessary components for the user to interact with the database. The database Engine, which is provided by DAO, encompasses the mechanism needed to interact with the database. The database store is essentially the database repository, storing all the data that the application uses, in a form that the database engine can manipulate.

The Database Store can be one of a variety of different database types. The Database Store can be located either locally or remotely when using DAO:

  • Local Database Store: All the components of the DAO application architecture reside on the same computer.
  • Remote Database Store: Can be broken down further into two distinct configurations:
  • Client/Server database configuration: The Database Engine and Database Store reside on the same server computer, while the User Interface resides on the client computer. The server computer can manage multiple client applications simultaneously.
  • Remote database configuration: The Database Store resides on the remote comoputer, while the User Interface and the Database Store Engine reside on the same client computer. In this configuration, the server computer simply manages access to the Database Store files.

A true client/server database engine simply serves as a communication layer between the database and the application. The DAO Jet database engine is not a true client/server database engine.

Each application that is developed using DAO Jet Database Engine requires a local copy of the DAO DLL files, to access the database, even if the application is running multiple client computers. However, you can create client/server applications using DAO by connecting to Open Database Connectivity (ODBC) database sources.


Connecting to a Database

The first step in developing your application by using DAO involves initializing your database engine and establishing connection to your database. Before you begin this first step, you need to understand how to use the three objects that form the foundation of DAO: DBEngine, Workspace, and Database.

To use DAO in your Visual Basic application, your application must include the DAO Object Library. To add the Object Library for you application:

1. Open you Visual Basic project.
2. Select Project —> References, to display the References dialog box.
3. The latest version of the DAO object Library is 3.6. Select Microsoft DAO 3.51 Object Library from the Available References list by clicking the checkbox next to the name entry.
4. Click OK to make the DAO Object Library available to your application.


Connections Object


A Connections collection contains the current Connection object of a Workspace object. The Connections objects has one property Count, which returns the number of objects in a collection. The Connections object has one method, Refresh(), whose syntax is Refresh, with no parameters. This method updates the objects in a collection to reflect the current database's schema.

Connection Object


A Connection is a non-persistent object that represents a connection to a remote database. The Connection object is only available in ODBCDirect workspaces.


Connection Object Properties
Property Description
Connect Sets or returns a value that provides information about the source of an open connection, an open database, a database used in a pass-through query, or a linked table. For Database objects, new Connection objects, linked tables, and TableDef objects not yet appended to a collection, this property setting is a read/write. For QueryDef objects and base tables, this property is read-only.
Name Sets or returns a user-defined name for a DAO object. For an object not appended to a collection, this property is read/write.
QueryTimeout Sets or returns a value that specifies the number of seconds to wait before a timeout error occurs when a query is executed on an ODBC data source.
RecordsAffected Returns the records affected by the recently invoked Execute() method
Updatable Returns a value that indicates whether you can change a DAO object.
Transactions Returns a value that indicates whether an object supports transactions.
Database Returns a Database object that corresponds to this connection.
StillExecuting Indicates whether an asynchronous operation has finished executing.



Connection Object Methods
Method Description
Close() Closes an open DAO object.
CreateQueryDef() Creates a new QueryDef object in a specified Connection or Database object.
Execute() Runs an action query or executes an SQL statement on a specified Connection.
OpenRecordSet() Creates a new Recordset object and appends it to the Recordsets collection
Cancel() Cancels execution of an asynchronous method call.





<<Back
top
Next>>





Copyright� 2000 by Noel