Private Sub cmdCreate_Click()
Dim cat As ADOX.Catalog Dim tbl As ADOX.Table Dim con As ADODB.Connection ' Delete the database if it already exists. On Error Resume Next Kill txtDatabaseName.Text On Error GoTo 0 ' Create the new database. Set cat = New ADOX.Catalog cat.Create _ "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & txtDatabaseName.Text & ";" ' Create a new table. Set tbl = New ADOX.Table tbl.Name = "TestTable" tbl.Columns.Append "FirstName", adVarWChar, 40 tbl.Columns.Append "LastName", adVarWChar, 40 cat.Tables.Append tbl ' Connect to the database. Set con = cat.ActiveConnection ' Insert a record. con.Execute "INSERT INTO TestTable VALUES ('Rod', 'Stephens')" Set con = Nothing Set tbl = Nothing Set cat = Nothing MsgBox "Done" End Sub 'Note that my version of the Visual Data Manager '(in the Add-Ins menu) cannot read the database created 'although my ADO programs can. In the project, add references to: Microsoft ActiveX Data Objects 2.5 Library Microsoft ADO Ext. for DDL and Security |