Results 1 to 3 of 3

Thread: Create table using Jet.OLEDB.3.51?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Posts
    20
    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.

  2. #2
    Lively Member Dr_Evil's Avatar
    Join Date
    Mar 2000
    Location
    Columbus, OH
    Posts
    105
    For the database:
    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
    For the table:
    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
    [Edited by Dr_Evil on 04-03-2000 at 10:26 AM]

  3. #3
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width