Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to create a new xx.mdb(MS access file) file using qt?
QtWS25 Last Chance

How to create a new xx.mdb(MS access file) file using qt?

Scheduled Pinned Locked Moved General and Desktop
sqlaccess
4 Posts 3 Posters 2.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • MactarvishM Offline
    MactarvishM Offline
    Mactarvish
    wrote on last edited by
    #1

    When I use sqlite, if I wanna create a new xx.db file, I usually use this function:

    ...
    QSqlDatabase::setDatabaseName("test.db");
    ...

    If the test.db is NOT exist, qt will create it automatically. But when I turn to MS access and still use this function:

    ...
    QSqlDatabase accessdb = QSqlDatabase::addDatabase("QODBC", "test");
    QString dsn = QString("DRIVER={Microsoft Access Driver (*.mdb)};FIL={MS Access};DBQ=mytest.mdb");
    accessdb.setDatabaseName(dsn);
    if (!accessdb.open())
    {
    qDebug() << accessdb.lastError().text();
    }
    ...

    I can only be told “[Microsoft][ODBC Microsoft Access driver] file not found '(unknown)'"
    which might means qt only find it without creating it automatically.

    How to create a new xx.mdb file using qt?

    1 Reply Last reply
    0
    • jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      It looks like your Qt installation does not contain the driver for MS Access

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      MactarvishM 1 Reply Last reply
      0
      • jsulmJ jsulm

        It looks like your Qt installation does not contain the driver for MS Access

        MactarvishM Offline
        MactarvishM Offline
        Mactarvish
        wrote on last edited by
        #3

        @jsulm But I'm sure I installed it formly...

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi and welcome to devnet,

          I haven't used ODBC actively but IIRC, you have to do some setup in order to access MSAccess databases through it (not unlike what you would have to do for a MySQL database) so basically you have to provide the .mdb file.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved