DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Can I use ADO to create a database file?

  1. #1
    Scott Campbell Guest

    Can I use ADO to create a database file?

    What happens if the file specified in the connection string does not exist?
    I want to create a new database if this is the case, how do I pull this off?

    I could use DAO, but then why would I be using ADO?
    The ADOX object seems to work, but then Access copmplains about an
    unsupported format.

    Am I screwed? Do I have to resort to maintaining a dummy file and using
    copy/rename to make this work, yuck.



  2. #2
    Paul Clement Guest

    Re: Can I use ADO to create a database file?

    On Wed, 27 Sep 2000 09:45:51 -0700, "Scott Campbell" <scampbell@irori.com> wrote:

    ¤ What happens if the file specified in the connection string does not exist?
    ¤ I want to create a new database if this is the case, how do I pull this off?
    ¤
    ¤ I could use DAO, but then why would I be using ADO?
    ¤ The ADOX object seems to work, but then Access copmplains about an
    ¤ unsupported format.
    ¤
    ¤ Am I screwed? Do I have to resort to maintaining a dummy file and using
    ¤ copy/rename to make this work, yuck.
    ¤

    Here's an example using ADOX:

    Sub CreateAccessDBWithADOX()

    Dim tbl As New ADOX.Table
    Dim col As New ADOX.Column
    Dim cat As New ADOX.Catalog

    'Engine Type=4 is Access 97 and a value of 5 is Access 2000
    cat.Create "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=c:\My Documents\NewDB.mdb;" & _
    "Jet OLEDB:Engine Type=4;"

    tbl.NAME = "NewTable"
    col.NAME = "Column1"
    col.Type = adLongVarWChar
    tbl.Columns.Append col
    cat.Tables.Append tbl

    Set cat = Nothing

    End Sub


    Paul ~~~ pclement@ameritech.net
    Microsoft MVP (Visual Basic)

  3. #3
    Scott Campbell Guest

    Re: Can I use ADO to create a database file?

    This is why you're an MVP!



  4. #4
    William Strutts Guest

    Re: Can I use ADO to create a database file?


    Paul Clement <UseAdddressAtEndofMessage@swspectrum.com> wrote:

    >Here's an example using ADOX:
    >
    >Sub CreateAccessDBWithADOX()
    >
    >Dim tbl As New ADOX.Table
    >Dim col As New ADOX.Column
    >Dim cat As New ADOX.Catalog
    >
    >'Engine Type=4 is Access 97 and a value of 5 is Access 2000
    >cat.Create "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    > "Data Source=c:\My Documents\NewDB.mdb;" & _
    > "Jet OLEDB:Engine Type=4;"
    >
    >tbl.NAME = "NewTable"
    >col.NAME = "Column1"
    >col.Type = adLongVarWChar
    >tbl.Columns.Append col
    >cat.Tables.Append tbl
    >
    >Set cat = Nothing
    >
    >End Sub
    >
    >
    >Paul ~~~ pclement@ameritech.net
    >Microsoft MVP (Visual Basic)


    My question is what is the ADOX object a part of? I can't
    seem to find it. I might have the wrong version ADO installed
    but I can't seem to tell. The data provider version that I get
    is Microsoft.Jet.OLEDB.3.51 which seems to be ADO 2.0? I assume
    that this is an old version because I can't find a catalog
    object. I had to DAO in my last project because I needed
    to access a querydef and you can't do it with the version of
    ADO I have. Is there a similar structure to a querydef in
    a newer version of ADO. The Info I had was that you could
    do it with the catalog object in ADOX but I can't find the
    library or like I said before, I probably have the wrong version.
    I need to know what version I need so that I can bug the IT
    people and get it installed.

    Thanks,

    Bill Strutts


  5. #5
    Paul Clement Guest

    Re: Can I use ADO to create a database file?

    On 28 Sep 2000 08:34:33 -0700, "William Strutts" <wrstrutts@ameritech.net> wrote:


    ¤ My question is what is the ADOX object a part of? I can't
    ¤ seem to find it. I might have the wrong version ADO installed
    ¤ but I can't seem to tell. The data provider version that I get
    ¤ is Microsoft.Jet.OLEDB.3.51 which seems to be ADO 2.0? I assume
    ¤ that this is an old version because I can't find a catalog
    ¤ object. I had to DAO in my last project because I needed
    ¤ to access a querydef and you can't do it with the version of
    ¤ ADO I have. Is there a similar structure to a querydef in
    ¤ a newer version of ADO. The Info I had was that you could
    ¤ do it with the catalog object in ADOX but I can't find the
    ¤ library or like I said before, I probably have the wrong version.
    ¤ I need to know what version I need so that I can bug the IT
    ¤ people and get it installed.

    Look in the project References dialog. Most of the ADO references are version specific and if you
    don't have one that is version specific it probably predates 2.0.

    ADOX is listed as Microsoft ADO Ext 2.x for DDL and Security (where x is the minor ADO version
    number) in the project References description.

    There is no QueryDef object in ADO -- Creating a QueryDef is a function of the Command object using
    the CommandText and Prepared properties. If you simply want to run a QueryDef, then all you need to
    do is use the Execute method of the Command object.


    Paul ~~~ pclement@ameritech.net
    Microsoft MVP (Visual Basic)

  6. #6
    Jman Guest

    Re: Can I use ADO to create a database file?

    You can also use the CREATE TABLE sql statement. It works quite well, even
    with Access databases.

    Scott Campbell escribió en mensaje <39d22240@news.devx.com>...
    >What happens if the file specified in the connection string does not exist?
    >I want to create a new database if this is the case, how do I pull this

    off?
    >
    >I could use DAO, but then why would I be using ADO?
    >The ADOX object seems to work, but then Access copmplains about an
    >unsupported format.
    >
    >Am I screwed? Do I have to resort to maintaining a dummy file and using
    >copy/rename to make this work, yuck.
    >
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center