Results 1 to 5 of 5

Thread: model->select() gives error "you have an error in your syntax" etc.

  1. #1
    Join Date
    Dec 2007
    Location
    Groningen Netherlands
    Posts
    182
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default model->select() gives error "you have an error in your syntax" etc.

    Hello,

    Don't know what happens here, it's just a plain litte table.
    The error msg is: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'index, ip, name, pass FROM members' at line 1 QMYSQL: Unable to execute query"
    It's the only table that produces this error.
    QSqlQuery on it works and shows the content.

    Qt Code:
    1. db = QSqlDatabase::addDatabase("QMYSQL");
    2. db.setHostName("192.168.1.10");
    3. db.setDatabaseName("iris");
    4. db.setUserName("me");
    5. db.setPassword("pass");
    6. if (!db.open())
    7. setWindowTitle(db.lastError().text());
    8. model = new QSqlTableModel;
    9. model->setTable("members");
    10. if (!model->select())
    11. qDebug() << model->lastError().text();
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 15th February 2008 at 11:58. Reason: missing closing quote

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: model->select() gives error "you have an error in your syntax" etc.

    Is that MySQL 4 or higher?
    J-P Nurmi

  3. #3
    Join Date
    Dec 2007
    Location
    Groningen Netherlands
    Posts
    182
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: model->select() gives error "you have an error in your syntax" etc.

    Yes this is 5.0.15

    I now use a tablewidget and a query which suited me better, though I thought I'd ask anyway..

  4. #4
    Join Date
    Nov 2007
    Posts
    51
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Default Re: model->select() gives error "you have an error in your syntax" etc.

    I may be mistaken on this, but isn't index a mysql keyword? You are using it without prefixing it with the table name and without ' '.

  5. #5
    Join Date
    Dec 2007
    Location
    Groningen Netherlands
    Posts
    182
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: model->select() gives error "you have an error in your syntax" etc.

    You are right. I didn't know that. It tests ok with another fieldname.

    Thanks.

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.