Can any one give me the coding for creating the db and the table by using the Jet.OLEDB.3.51 but not the 4.0 one, thanx.
Printable View
Can any one give me the coding for creating the db and the table by using the Jet.OLEDB.3.51 but not the 4.0 one, thanx.
For the database:
For the table:Code:Private Sub NewDatabase_Click()
Dim db As Database
CommonDialog1.ShowSave
If CommonDialog1.FileName <> "" Then
Set db = DBEngine.Workspaces(0).CreateDatabase
(CommonDialog1.FileName, dbLangGeneral)
End If
End Sub
[Edited by Dr_Evil on 04-03-2000 at 10:26 AM]Code:Sub CreateTable()
Dim td As TableDef
Dim fields(2) As Field
Set td = db.CreateTableDef(name,attributes,source,connect)
Set fields(0) = td.CreateField(name, type, size)
Set fields(1) = td.CreateField(name, type, size)
td.fields.Append fields(0)
td.fields.Append fields(1)
End Sub
That is DAO code, Dr Evil!
Here is ADO code to create a DB:
Code:'use ADO 2.x for DDL and security
Dim strConnectionStringOfNewDB As String
Dim objCat As ADOX.Catalog
'instantiate catalog object
Set objCat = New ADOX.Catalog
'connection string of new db -- includes driver/db type and location
strConnectionStringOfNewDB = "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=C:\NewDB.mdb"
'create it
objCat.Create strConnectionStringOfNewDB
'cleanup
Set objCat = Nothing