Results 1 to 4 of 4

Thread: QSQL error on insert into statement

  1. #1
    Join Date
    Feb 2013
    Posts
    71
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QSQL error on insert into statement

    Hi, I'm working on a program where I get user input and insert that value to my database. At the moment, I'm getting the following error:
    QSqlError(-1, "Unable to fetch row", "No query")
    But I know thats its not my coding because when I try a select statement, it works fine with no problems. My INSERT INTO statement is as follows:
    Qt Code:
    1. str = pLineEdit->text();
    2. QString qry = QString("INSERT INTO customer (name, phone_no, address, city) VALUES ('%%1%', NULL, NULL, NULL").arg(str);
    To copy to clipboard, switch view to plain text mode 

    Is my INSERT statement correct?

  2. #2
    Join Date
    Feb 2013
    Posts
    71
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QSQL error on insert into statement

    Figured it out, syntax wasn't correct, all good and working now!

  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,004 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QSQL error on insert into statement

    Good, but seriously take a look at QSqlQuery::prepare() to avoid SQL-Injections.

  4. #4
    Join Date
    Feb 2013
    Posts
    71
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QSQL error on insert into statement

    Got it, thanks!

Similar Threads

  1. qsqlquery insert error
    By fantom in forum Qt Programming
    Replies: 4
    Last Post: 23rd February 2011, 17:15
  2. QSql error with include in Visual Studio 2008
    By svetlio.zhelev in forum Newbie
    Replies: 1
    Last Post: 15th September 2010, 22:19
  3. i need to know insert and delete methods in qsql for phone book application
    By gaurav purohit in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 15th September 2009, 14:04
  4. WinSeven,QSQL plugin,error
    By Fastman in forum Qt Programming
    Replies: 0
    Last Post: 9th May 2009, 20:49
  5. QSql error
    By renjithmamman in forum Qt Programming
    Replies: 4
    Last Post: 20th December 2006, 10:28

Tags for this Thread

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.