Results 1 to 2 of 2

Thread: Problem inserting data into sqlite

  1. #1
    Join Date
    Apr 2011
    Posts
    67
    Thanks
    22
    Thanked 5 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Problem inserting data into sqlite

    I have the following code in my save function.

    Qt Code:
    1. void smith::on_saveButton_clicked()
    2. {
    3.  
    4. QSqlQuery query;
    5.  
    6. query.prepare(
    7. "INSERT INTO application (firstname, lastname, country, city)) "
    8. "VALUES (:firstname, :lastname, :country, :city)"
    9. );
    10.  
    11. query.bindValue(":firstname", "Alexis");
    12. query.bindValue(":lastname", "Nicholov");
    13. query.bindValue(":country", "Russia");
    14. query.bindValue(":city","Moscow");
    15. query.exec();
    16. }
    To copy to clipboard, switch view to plain text mode 

    The database connection is alright but it wont insert.Why?.

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

    Default Re: Problem inserting data into sqlite

    What error do you get? See QSqlQuery::lastError().


    EDIT: You have a ) to much after city

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

    thefatladysingsopera (12th August 2011)

Similar Threads

  1. Replies: 6
    Last Post: 30th January 2011, 09:11
  2. Replies: 4
    Last Post: 19th December 2010, 06:15
  3. QTableWidget - inserting data
    By Tomasz in forum Newbie
    Replies: 1
    Last Post: 29th September 2010, 14:32
  4. Problem while inserting the data into database
    By sudheer168 in forum Qt Programming
    Replies: 2
    Last Post: 13th December 2008, 12:22

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
  •  
Qt is a trademark of The Qt Company.