Databases Reference
In-Depth Information
Figure 18-1. The ADOX object model
' Must use version 3.51 of data provider in order
' to create a database compatible with Access 97.
' If this is not required, can use version 4.0.
cat.Create "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=d:\temp\ADOXExample.mdb"
End Sub
Note that if the database already exists, an error will be generated. Incidentally, the
ADOX documentation says: “The
Create
method creates and opens a new ADO
Connection to the data source specified in ConnectString.” This seems to imply that the
data source must already exist, which is, of course, not the case.
18.1.2 Creating Tables
A Jet table in ADOX is created as follows:
1.
Create a
Table
object.
2.
Give it a name by assigning a string containing the name to the
Table
object's
Name property.
3.
Append some columns to the
Table
object's
Columns
collection. Do this by
calling the
Append
method of the
Column
collection. Its syntax is: