aak_neo Level: Scholar

 Registered: 11-02-2007 Posts: 30
|
how to make database using ado object library at run time!!!
i have a program that on the click of a button provides dbpath & calls a function that makes a db.
this is the function:
Sub CreateDb(Path As String)
Dim db As Database
Dim table As TableDef
Dim soru As Field
Dim pic As Field
Dim zorlukderecesi As Field
Dim ders As Field
Dim sinif As Field
Dim unite As Field
'Create Database
Set db = CreateDatabase(Path, dbLangGeneral, dbEncrypt)
'Create Table
Set table = db.CreateTableDef("Deneme")
'Create Fields.
'For see all datatypes press F2. Library "DAO" and Classes "DataTypeEnum"
Set soru = table.CreateField("Soru", dbMemo, 0)
Set pic = table.CreateField("Pic", dbMemo, 0)
Set zorlukderecesi = table.CreateField("zorlukderecesi", dbText, 20)
Set ders = table.CreateField("Ders", dbText, 50)
Set sinif = table.CreateField("Sinif", dbText, 50)
Set unite = table.CreateField("Unite", dbText, 10)
'Add Fields to Table
table.Fields.Append soru
table.Fields.Append pic
table.Fields.Append zorlukderecesi
table.Fields.Append ders
table.Fields.Append sinif
table.Fields.Append unite
'Add Table to Database
db.TableDefs.Append table
MsgBox "Your Database which name is " & table.Name & " And which version is " & db.Version & vbCrLf & _
"created at " & table.DateCreated & " has " & table.Fields.Count & " Fields", vbInformation, "Create Database"
End Sub
Private Sub Command1_Click()
CreateDb App.Path & "\" & "Data.mdb"
End Sub
it gives me a type mismatch error wen it starts setting the fields.
i have been using ado throughout so wanted to know if there's a way to make a db in ado object library so that i will not have to study dao also.
plz reply with some code or examples.
[Edited by aak_neo on 07-03-2007 at 08:18 PM GMT]
____________________________
You never see past the choices you don't understand
|