borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (change the width of column in access table)Next Topic (How to view the Date Format like DD/MM/YYYY in MSHFlexGrid) New Topic New Poll Post Reply
AndreaVB Forum : Database : how to make database using ado object library at run time!!!
Poster Message
aak_neo
Level: Scholar


Registered: 11-02-2007
Posts: 30

icon 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

07-03-2007 at 03:15 PM
View Profile Send Email to User Show All Posts | Quote Reply
gauravvmahhajan
Level: Trainee

Registered: 07-05-2007
Posts: 1
icon Re: how to make database using ado object library at run time!!!

if you are using Access then

open app.path & "\database.mdb" for output as #1
close #1

dim cn as ADODB.connection
cn.provider="Microsoft.jet.oledb.4.0"
cn.open app.path & "\database.mdb"

cn.Execute "Create table A (name varchar(50), address varchar(300))"

____________________________
gaurav mahajan

07-05-2007 at 02:44 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
aak_neo
Level: Scholar


Registered: 11-02-2007
Posts: 30
icon Re: how to make database using ado object library at run time!!!

THANX FOR HELP DUDE BUT I FINISHED MY PROJECT LONG BACK SEE THE POST DATE if u need help on ado & related problems read some of my posts u will find the basic troubles we face in ado.
best of luck

____________________________
You never see past the choices you don't understand

07-05-2007 at 03:36 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Database : how to make database using ado object library at run time!!!
Previous Topic (change the width of column in access table)Next Topic (How to view the Date Format like DD/MM/YYYY in MSHFlexGrid) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder