Databases Reference
In-Depth Information
Chapter 18. ADOX: Jet Data Definition in ADO
ADOX is an acronym for ADO Extensions for Data Definition and Security . When
making comparisons between ActiveX Data Objects (ADO) and Data Access Objects
(DAO), proponents of DAO will point out that ADO does not include features for data
definition—that is, features that can be used to create and alter databases and their
components (tables, columns, indexes, etc.). This is precisely the purpose of ADOX, but
not just in the context of Jet databases. ADOX is intended to be a universal data-
definition object model. Of course, as with ADO, it requires support from OLE DB data
providers. Our concern is with ADOX in relation to Jet.
I plan to discuss the role of ADOX in various data definition operations, such as creating
a Jet database and creating and altering Jet database tables.
It is worth mentioning that ADOX is not a complete substitute for DAO's data-definition
features. For example, query creation in ADOX has a serious wrinkle (at least for Access
2000). Namely, a query created using ADOX will not appear in the Access 2000 user
interface! We will revisit this issue later in this chapter.
18.1 The ADOX Object Model
The ADOX object model is shown in Figure 18-1. The model has 9 object pairs
(object/collection), about 75 properties, and about 50 methods—not a very large object
model as Microsoft object models go (and smaller than the ADO object model).
Unfortunately, the ADOX help documentation is among Microsoft's worst, which is
saying a lot.
Let's now look at some of the more common data-definition operations from the
perspective of ADOX.
18.1.1 Creating a Database
To create a Jet database, use the Create method of the Catalog object. Its syntax is:
CatObject .Create( ConnectString )
where ConnectString is a connection string that must also define the database to be
created.
The following code creates a new Jet database:
Sub CreateDatabase( )
Dim cat As New Catalog
 
 
Search WWH ::




Custom Search