引用 Microsoft ADO Ext. 2.7 for DDL and SecurityThe following code shows how to create a new Microsoft Jet database with the Create method.Attribute VB_Name = "Create" Option Explicit' BeginCreateDatabseVB Sub CreateDatabase() Dim cat As New ADOX.Catalog cat.Create "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\new.mdb"End Sub ' EndCreateDatabaseVBThe following code demonstrates how to create a new table.' BeginCreateTableVB Sub CreateTable() Dim tbl As New Table Dim cat As New ADOX.Catalog'Open the catalog. ' Open the Catalog. cat.ActiveConnection = _ "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=c:\Program Files\Microsoft Office\" & _ "Office\Samples\Northwind.mdb;" tbl.Name = "MyTable" tbl.Columns.Append "Column1", adInteger tbl.Columns.Append "Column2", adInteger tbl.Columns.Append "Column3", adVarWChar, 50 cat.Tables.Append tblEnd Sub
Option Explicit' BeginCreateDatabseVB
Sub CreateDatabase() Dim cat As New ADOX.Catalog
cat.Create "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\new.mdb"End Sub
' EndCreateDatabaseVBThe following code demonstrates how to create a new table.' BeginCreateTableVB
Sub CreateTable() Dim tbl As New Table
Dim cat As New ADOX.Catalog'Open the catalog.
' Open the Catalog.
cat.ActiveConnection = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\Program Files\Microsoft Office\" & _
"Office\Samples\Northwind.mdb;" tbl.Name = "MyTable"
tbl.Columns.Append "Column1", adInteger
tbl.Columns.Append "Column2", adInteger
tbl.Columns.Append "Column3", adVarWChar, 50
cat.Tables.Append tblEnd Sub