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
Re: Hot to insert row to SQLite database?
UP
How to insert row to SQLite database?
Re: Hot to insert row to SQLite database?
Using QT or SQLite3 client?
Mecland
Re: Hot to insert row to SQLite database?
I would expect,
Code:
QSqlRecord record
= model
->record
();
// get your template record from model record.setValue(...);
model->insertRecord(-1, record); // append record at end
model->submitAll(); // depends on edit behaviour
This is untested code ;-)
Re: Hot to insert row to SQLite database?
Thank you I will try it.
I am using Qt
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
Re: Hot to insert row to SQLite database?
Hi;
try [WIKI]http://doc.trolltech.com/4.3/demos-sqlbrowser.html[/WIKI].