Results 1 to 7 of 7

Thread: Quick DB question

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Quick DB question

    ok how do you create a new access Database in a set location useing ADO

    and how can you create a new table (using code) using ado and access

    and finally how can you view all the tables in a set database


    thanks sorry for all the questions just need to clear something up

    PINO

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132
    Set references to MS ADO Ext. x.x DDL and Security and run this sample:
    VB Code:
    1. Private Sub Command2_Click()
    2. '=============================
    3. Dim tbl As New ADOX.Table
    4. Dim cat As New ADOX.Catalog
    5. Dim sSQL$
    6.  
    7.     sSQL = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    8.                  "Data Source=" & App.Path & "\NewDB.mdb;" & _
    9.                  "Jet OLEDB:Engine Type=5"
    10.     cat.Create sSQL
    11.     tbl.Name = "Test_Table"
    12.     tbl.Columns.Append "Field1", adInteger
    13.     tbl.Keys.Append "PrimaryKey", adKeyPrimary, "Field1"
    14.     cat.Tables.Append tbl
    15.    
    16.     Set cat = Nothing
    17.     Set tbl = Nothing
    18.  
    19. End Sub

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787
    when i try and open the created DB it says unrecognized format.....cant i view it visually?

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787
    and this line errors...


    cat.Tables.Append tbl

  5. #5
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132
    What version of ADO are you using - you may need 2.6

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787
    using 2.7

  7. #7
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132
    I might be wrong but I think 2.7 is for Access 2002 so get 2.6 from MS - you may have multiple versions installed without any conflict.

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