Share via

Create Access database programmatically C++

Anonymous
2014-07-16T10:38:09+00:00

I want to create a database in MSAccess 2010 programmatically in C++

It is being used in a library [which is used by a windows form application]. 

"ADODB " is used here. I have the code for opening the database.

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

4 answers

Sort by: Most helpful
  1. Anonymous
    2014-07-24T04:45:05+00:00

    I was not able to find any code that creates a database in c++, so at last i used c#. Ported the code. 

    thanks,

    0 comments No comments
  2. Anonymous
    2014-07-16T11:19:18+00:00

    thanks for the reply. 

    Sorry i didn't mention i was looking code in C++

    0 comments No comments
  3. Anonymous
    2014-07-16T11:05:07+00:00

    Correction to the code I posted...

    In the "cleanup" commands, change objDB.Quit to objDB.Close:

    Sub TestDB()

        Dim objDb As Database

        Dim strPath As String

        strPath = "C:\test\Test.accdb"

        Set objDb = Application.DBEngine.CreateDatabase(strPath, dbLangGeneral)

        ' Clean up objects when done...

        objDb.Close

        Set objDb = Nothing

    End Sub

    0 comments No comments
  4. Anonymous
    2014-07-16T10:55:19+00:00

    This will create a new database in Access vba:

    Dim objDb as Database

    dim strPath as string

    strPath = "C:\Test.accdb"

    Set objDB = Application.DBEngine.CreateDatabase(strPath``, dbLangGeneral)

    ' Clean up objects when done...

    objDB.Quit

    Set objDB = nothing

    0 comments No comments