Results 1 to 7 of 7

Thread: How to insert row to SQLite database?

  1. #1
    Join Date
    Aug 2009
    Location
    Saudi Arabia - Buraidah
    Posts
    48
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to insert row to SQLite database?

    Hi,

    I am using SQLite database with QSqlTableModel and QDataWidgetMapper.

    I want to insert a new row and save to the database file "database.db"

    I have tried "insertRecord" and "insertRows" but I could not save the inserted row to the "database.db" file.

    Any clue?

    Thanks,
    Mohammad
    http://brainstorm.ubuntu.com/idea/24714/image/1/
    The Linux Counter Project - user number # 497262
    The Ubuntu Counter Project - user number # 29025

  2. #2
    Join Date
    Aug 2009
    Location
    Saudi Arabia - Buraidah
    Posts
    48
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Hot to insert row to SQLite database?

    UP
    How to insert row to SQLite database?
    http://brainstorm.ubuntu.com/idea/24714/image/1/
    The Linux Counter Project - user number # 497262
    The Ubuntu Counter Project - user number # 29025

  3. #3
    Join Date
    May 2010
    Posts
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Hot to insert row to SQLite database?

    Using QT or SQLite3 client?

    Mecland

  4. The following user says thank you to mecland for this useful post:

    MIH1406 (3rd June 2010)

  5. #4
    Join Date
    Sep 2008
    Location
    Munich
    Posts
    32
    Thanked 8 Times in 6 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Hot to insert row to SQLite database?

    I would expect,

    Qt Code:
    1. QSqlTableModel *model = ...
    2. QSqlRecord record = model->record(); // get your template record from model
    3. record.setValue(...);
    4. model->insertRecord(-1, record); // append record at end
    5. model->submitAll(); // depends on edit behaviour
    To copy to clipboard, switch view to plain text mode 

    This is untested code ;-)

  6. The following user says thank you to jryannel for this useful post:

    MIH1406 (3rd June 2010)

  7. #5
    Join Date
    Aug 2009
    Location
    Saudi Arabia - Buraidah
    Posts
    48
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Hot to insert row to SQLite database?

    Thank you I will try it.
    I am using Qt
    http://brainstorm.ubuntu.com/idea/24714/image/1/
    The Linux Counter Project - user number # 497262
    The Ubuntu Counter Project - user number # 29025

  8. #6
    Join Date
    Aug 2009
    Location
    Saudi Arabia - Buraidah
    Posts
    48
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Hot to insert row to SQLite database?

    Hi jryanne,

    I tried your code but it does not do anything? Any clue?

    Thank you,
    Mohammad
    http://brainstorm.ubuntu.com/idea/24714/image/1/
    The Linux Counter Project - user number # 497262
    The Ubuntu Counter Project - user number # 29025

  9. #7
    Join Date
    May 2010
    Location
    Algeria
    Posts
    23
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Hot to insert row to SQLite database?

    Hi;
    try [WIKI]http://doc.trolltech.com/4.3/demos-sqlbrowser.html[/WIKI].

Similar Threads

  1. Insert unicode in SQlite
    By Kastagne in forum Qt Programming
    Replies: 3
    Last Post: 11th October 2011, 14:07
  2. Replies: 2
    Last Post: 13th April 2010, 16:50
  3. Sqlite multipule row insert question
    By rogerholmes in forum Newbie
    Replies: 5
    Last Post: 31st December 2009, 16:36
  4. SQLite sometimes doens't INSERT into database
    By cevou in forum Qt Programming
    Replies: 5
    Last Post: 30th October 2009, 08:10
  5. Bulk insert into SQLite
    By munna in forum Qt Programming
    Replies: 6
    Last Post: 19th November 2007, 03:56

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.