The RDO object model is designed as a thin wrapper around the ODBC interface, providing a Visual Basic object model to the interface that can be used with all of the Visual Basic bound controls. In a lot of ways, the RDO object model is very similar to the DAO object model. The primary difference between the two is that the DAO object model was designed around ISAM (Indexed Sequential Access Method, also known as Flat-File) database access, while the RDO object model was designed for SQL (Structured Query Language) database access. This means that DAOs are well suited for working with databases like dBase, FoxPro, and Paradox, while RDOs are better suited for use with databases like SQL Server, Oracle, and Sybase.
The RDO object model consists of the following objects:
rdoEngine - This is the base object, which is created automatically whenever RDOs are used in a Visual Basic application.
rdoError - This object performs all of the RDO and ODBC error and message handling.
rdoEnvironment - This object controls a logical set of connections and transactions. There can be multiple rdoEnvironment objects, but the first one is automatically created by the rdoEngine.
rdoConnection - This object represents an open connection to a specific database.
rdoTable - This object represents the stored definition of a database table.
rdoResultset - This object represents the rows of data that result from a query run against the database.
rdoColumn - This object represents a column of data.
rdoQuery - This object represents a SQL query that can contain zero or more parameters.
rdoParameter - This object represents a parameter associated with a rdoQuery object. This parameter can be an input parameter, output parameter, or both.
The relationships between these objects are shown in Figure 23.9.
The RDO object model, showing the relationships between the objects, is very similar to the DAO object model.
For the most part, RDOs can be used in much the same way that DAOs are used. The following are a few notable differences that must be taken into account:
RDOs use the term rows instead of records, and columns instead of fields.
RDOs do not allow you to use the Seek method to locate a record, because that is an ISAM search method where the DAOs have direct access to the database indexes.
RDOs do not allow direct modification of the database schema, referential integrity, or security, because these are fully supported by the database administration tools. RDOs can use the native database Data-Definition Language (DDL) to perform these same tasks.
In Table 23.1, you can see the RDO objects and their corresponding DAO objects.
Table 23.1 - RDO Objects and Their Corresponding DAO Objects
RDO Objects |
DAO Objects |
rdoEngine |
DBEngine |
rdoError |
Error |
rdoEnvironment |
Workspace |
rdoConnection |
Database |
rdoTable |
TableDef |
N/A |
Index |
rdoResultset |
Recordset |
- N/A |
- Table-type |
- Keyset-type |
- Dynaset-type |
- Static-type |
- Snapshot-type |
- Dynamic-type |
- N/A |
- Forward-only |
- Forward-only |
- (cursorless) |
- N/A |
rdoColumn |
Field |
rdoQuery |
QueryDef |
rdoParameter |
Parameter |
N/A |
Relation |
N/A |
Group |
N/A |
User |
This provides you with a quick comparison of RDO and DAO object models, and hopefully provides you with an understanding of how you can build on your existing understanding of DAOs to use RDOs to build database applications in Visual Basic.