Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. SQLITE out of memory Unable to execute statement problem [SOLVED]
Forum Updated to NodeBB v4.3 + New Features

SQLITE out of memory Unable to execute statement problem [SOLVED]

Scheduled Pinned Locked Moved QML and Qt Quick
7 Posts 2 Posters 9.5k 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.
  • M Offline
    M Offline
    majidkhalili
    wrote on last edited by
    #1

    hi guys i'm almost new to qt
    i just tried to use sqlite in qt but I've got this error
    @
    qDebug() << QSqlDatabase::drivers();
    QSqlDatabase DB = QSqlDatabase::addDatabase("QSQLITE");
    DB.setDatabaseName("/Volumes/MAJID/majid/Naminic/db0.db");
    QSqlQuery createQuery;
    qDebug()<< "open: " << DB.open();
    createQuery.exec("CREATE TABLE contact(name,tell)");
    qDebug() << createQuery.lastError().text();

    qDebug() << "insert : " << createQuery.exec&#40;"insert into contact(name,tell&#41; values('a','b'&#41;");
    qDebug() << createQuery.lastError().text();
    

    @
    and this is the out put of the debug :
    ("QSQLITE", "QODBC3", "QODBC")
    open: true
    "out of memory Unable to execute statement"
    insert : false
    "out of memory Unable to execute statement"

    1 Reply Last reply
    0
    • O Offline
      O Offline
      onek24
      wrote on last edited by
      #2

      Hello and welcome to qt-project.org,

      i would recommend you to post Cpp things in the General and Desktop subforum because you probably will get an answer faster in there. "General and Desktop":http://qt-project.org/forums/viewforum/10/

      But now you're here and so the QtQuick-guys will try to help you. :)

      Well i would say that you'll have to prepare the query first and then execute it.
      @QSqlQuery query;
      query.prepare("INSERT INTO person (id, forename, surname) "
      "VALUES (:id, :forename, :surname)");
      query.bindValue(":id", 1001);
      query.bindValue(":forename", "Bart");
      query.bindValue(":surname", "Simpson");
      query.exec();@

      You can find that example and more information here:
      "QSqlQuery":http://qt-project.org/doc/qt-4.8/qsqlquery.html

      1 Reply Last reply
      0
      • M Offline
        M Offline
        majidkhalili
        wrote on last edited by
        #3

        thanks to QtQuick-guys ;)
        but as u see the results , it couldn't even create the table because of :
        “out of memory Unable to execute statement”

        1 Reply Last reply
        0
        • O Offline
          O Offline
          onek24
          wrote on last edited by
          #4

          Well i would still say that you'll have to create, prepare and then execute the statement:

          bq. bool QSqlQuery::exec (): Executes a previously prepared SQL query. Returns true if the query executed successfully; otherwise returns false.
          Note that the last error for this query is reset when exec() is called.

          Also you could try to clear before you execute your statement.
          "QSqlQuery::clear":http://qt-project.org/doc/qt-4.8/qsqlquery.html#clear

          If that won't work i'll search for another solution. :)

          1 Reply Last reply
          0
          • M Offline
            M Offline
            majidkhalili
            wrote on last edited by
            #5

            Dorod bar shoma
            that clear thing worked :D
            thanks a lot ;)

            1 Reply Last reply
            0
            • M Offline
              M Offline
              majidkhalili
              wrote on last edited by
              #6

              i don't know how to mark this post as solved , or how to thank to u by sths like voting up or sty like that ?!!!

              1 Reply Last reply
              0
              • O Offline
                O Offline
                onek24
                wrote on last edited by
                #7

                [quote author="majidkhalili" date="1392472478"]Dorod bar shoma
                that clear thing worked :D
                thanks a lot ;)[/quote]
                You're welcome, glad i could help you.

                [quote author="majidkhalili" date="1392472578"]i don't know how to mark this post as solved , or how to thank to u by sths like voting up or sty like that ?!!![/quote]

                • Just edit your main post, the one above every post. You'll find the edit button on the right side of your post. Then add [Solved] to your Title(It would be more visible in front of the Title.).
                • There are no votes or something like that in qt-project.org. A 'thank you' at all is more than enough. :)
                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