Microsoft database programming
object sets:
Data
Access Objects (DAO),
Remote
Data Objects (RDO), and
ActiveX
Data Objects (ADO).
DAO: When
Visual Basic first started working with databases, it used the Microsoft Jet
database engine, which is what Microsoft Access uses. 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
The
Data Control
The Data control
gives you access to databases without any programming. You can set a few
properties of the control and use regular controls such as textboxes to display
the values of the fields in the database.
The
data control’s Database and Recordset properties refer to those
Database and Recordset objects, and you can manipulate the data using those
properties.
RDO: Remote
Data Objects (RDO) connects to databases using ODBC. You set up ODBC
connections to databases using the ODBC item in the Windows Control Panel, and
then use one of those connections with the RDO objects. The Remote Data Objects
are designed in parallel with the Data Access Objects; for example, the
database engine is rdoEngine instead of DBEngine, Recordsets have become
rdoResultsets, TableDefs became rdoTables, Workspaces became rdoEnvironments,
Field objects became rdoColumn objects, and so on. Although the names have
changed, the command set is very similar to DAO.
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.
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 RecordSource property, but it
cannot accept the name of a table by itself unless you populate the rdoTables
collection first.
ADO: Microsoft’s
latest set of data access objects are the ActiveX Data Objects (ADO). These
objects let you access data in a database server through any OLE DB provider.
Here are the ADOs:
• Connection
• Command
• Parameter
• Recordset
• Field
• Erro
• Collection
• Event
The
ADO Data Control
The
ADO data control is similar to the data control and the remote data control.
The ADO data control is designed to create a connection to a database using
Microsoft ActiveX Data Objects (ADO). At design time, you create a connection
by setting the ConnectionString property to a valid connection string,
then set the RecordSource property to a statement appropriate to the
database manager.