Results 1 to 4 of 4

Thread: SQLITTE "unable to fetch row"

  1. #1
    Join Date
    May 2008
    Posts
    276
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default SQLITTE "unable to fetch row"

    I have two database connections (SQLITE).
    The second one is created by:
    Qt Code:
    1. bool MainWindow::createConnection(const QString &id)
    2. {
    3. databasePanels = QCoreApplication::applicationDirPath()+"/panels.db";
    4.  
    5. QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE",id);
    6.  
    7. db.setDatabaseName(databasePanels);
    8. db.open();
    9. /
    10. if (db.isOpen())
    11. return true;
    12. else
    13.  
    14. return false;
    15. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void MainWindow::createTablePanel(const QString &type)
    2. {
    3. QSqlDatabase db=QSqlDatabase::database(type);
    4. db.setDatabaseName(databasePanels);
    5. QSqlQuery q(db);
    6. q.prepare(" create table pannelli ( id INTEGER NOT NULL PRIMARY KEY,costruttore VARCHAR(50),modello VARCHAR(50),pnom )");
    7. q.exec();
    8.  
    9. }
    To copy to clipboard, switch view to plain text mode 
    but I get:

    createTablePanel.: QSqlError(-1, "Unable to fetch row", "No query") "

    why?

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: SQLITTE "unable to fetch row"

    maybe this table already exist?
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. The following user says thank you to spirit for this useful post:

    giusepped (20th January 2009)

  4. #3
    Join Date
    Mar 2010
    Posts
    92
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: SQLITTE "unable to fetch row"

    Quote Originally Posted by spirit View Post
    maybe this table already exist?
    Qt Code:
    1. void MainWindow::on_pushButton_clicked()
    2. {
    3. QSqlDatabase db = QSqlDatabase::addDatabase( "QSQLITE" );
    4. db.setDatabaseName( "C:/Users/BotNetVN/Desktop/TuDien/Disa.s3db" );
    5. QSqlQuery qry;
    6. QString qstrExe = "INSERT INTO word (ID_Word,English) VALUES (3,'" + ui->textEdit->toPlainText() + "')";
    7. qry.prepare( qstrExe );
    8. if (!qry.exec()){
    9. ui->textEdit->setText(qry.lastError().text());
    10. }
    11. else{
    12. ui->textEdit->setText("Them CSDL thanh cong");
    13. }
    14. db.close();
    15. }
    To copy to clipboard, switch view to plain text mode 

    why error No query Unable to fetch row

  5. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: SQLITTE "unable to fetch row"

    Where are you opening the database in MainWindow::on_pushButton_clicked()?
    Last edited by ChrisW67; 30th May 2010 at 23:25. Reason: Disabled smilies in text

Similar Threads

  1. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.