Page 251 - Open Soource Technologies 304.indd
P. 251
Unit 11: Data Base Access
11.1 The ADO Data Model
ADO is a language-neutral object model that lets you manipulate data accessed by an underlying
OLE DB provider. (An OLE DB provider is a data manager that interfaces directly with a database.
For example, Microsoft Jet is the data manager on which Microsoft Access is built.) ADO’s object
model is simpler than DAO’s, containing fewer objects and more properties, methods, and events,
and combining much of DAO’s functionality into single objects. Many of the objects in the ADO
data model are similar to RDO objects, but with enhanced functionality. For example, ADO’s
Recordset object contains records returned from a database plus the cursor for those records.
(A cursor helps manage and manipulate a set of data.) The Recordset object is similar to RDO’s
rdo Resultset object. With ADO, however, you can open a Recordset object without explicitly
connecting to the database source. And if you do connect to the database, you can open multiple
Recordset objects on the same connection. You can learn more about the ADO data model from
the references listed in where can I find out more about ADO?
11.2 Data Access Objects (DAO)
When Visual Basic first started working with databases, it used the Microsoft Jet database engine,
which is what Microsoft Access uses. Using the Jet engine represented a considerable advance for
Visual Basic, because now you could work with all kinds of data formats in the fields of a
database: text, numbers, integers, longs, singles, doubles, dates, binary values, OLE objects,
currency values, Boolean values, and even memo objects (up to 1.2GB of text). The Jet engine also
supports SQL, which database programmers found attractive. To support the Jet database engine,
Microsoft added the data control to Visual Basic, and you can use that control to open Jet database
(.mdb) files. Microsoft also added a set of Data Access Objects (DAO) to Visual Basic:
• DBEngine—The Jet database engine
• Workspace—An area can hold one or more databases
• Database—A collection of tables
• TableDef—The definition of a table
• QueryDef—The definition of a query
• Recordset—The set of records that make up the result of a query
• Field—A column in a table
• Index—An ordered list of records
• Relation—Stored information about the specific relationship between tables
11.3 The Remote Data Control
Like the data control, the remote data control gives you access to a database and displays data
in bound controls. Unlike the data control, however, you use the remote data control to access
ODBC data sources (which can include databases built with all the popular commercial database
programs).
As with the data control, if the remote data control is instructed to move to a different row, all
bound controls automatically pass any changes to the remote data control to be saved to the
ODBC data source. The remote data control then moves to the requested row and passes back
data from the current row to the bound controls where it’s displayed.
In fact, the remote data control behaves like the data control in most respects, with some differences;
for example, you can treat the remote data control’s SQL property like the data control’s.
LOVELY PROFESSIONAL UNIVERSITY 245