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. Unable to open SQLite database in UWP app
Forum Updated to NodeBB v4.3 + New Features

Unable to open SQLite database in UWP app

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 1.1k Views 1 Watching
  • 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.
  • F Offline
    F Offline
    FancyPants
    wrote on last edited by SGaist
    #1

    I am developing an app for Uniwersal Windows Platform. What I'm trying to do now is to create a SQLite database, but for UWP I'm getting the following error:

    QSqlError("-1", "Error opening database", "out of memory")

    To achieve this I'm using following code (which work perfectly fine for classic desktop app):

    QString dbpath = QCoreApplication::applicationDirPath() + DATABASE_NAME;
        db.setDatabaseName(dbpath);
        if(db.open()){
            return true;
        } else {
            qDebug() << db.lastError();
            return false;
        }
    

    Are there any additional steps to make it works for UWP app? Is it possible?

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Fuel
      wrote on last edited by
      #2

      Where do you load the Driver? Somewhere you need to load the SQLite Driver in your db Variable.

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

        Hi and welcome to devnet,

        Also note that the path your are trying to use will likely be read-only as with other mobile OSs like iOS and Android.

        You should use QStandardPaths to get a writable folder to store your database.

        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
        1
        • F Offline
          F Offline
          FancyPants
          wrote on last edited by
          #4

          Using QStandardPaths indeed solved my problem.

          Thanks SGaist.

          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