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



  • 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"



  • 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



  • 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”



  • 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. :)



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



  • 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 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. :)

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.