Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ Sqlite QT-Creator
Hi,
 
I just need help with my project. I am using Qt creator for Mobile symbian OS.
I just would like to know what is the best Insert Command to enable the user to save input data into SQLite.
 
I have this code:
void addtrnsc::on_pushButton_clicked()
{
    QSqlDatabase myDB = QSqlDatabase::addDatabase("QSQLITE");
    myDB.setDatabaseName(Path_to_DB);
 
    if (!myDB.open())
    {
        QMessageBox::critical(0, tr("no Con"), tr("unable to stablish"));
        return;
 
    }
    QSqlQuery query;
    query.exec("insert into expense values(Descrition, Amount, Type, Date) VALUES ("+ui->txtDescrip->text()+","+ui->txtamount->text()+","+ui->comboxtype->currentText()+","+ui->dateEdit->text());
}
 
or can you give me a sample logic that will insert input data to databse..
 
I do not know if what is next and I do not know if it will work.
Can someone please help me with this?
 
Thanks
Posted 25-Jan-13 11:37am
Edited 25-Jan-13 12:15pm
v4

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

This will help with your insert statement,
 
http://www.w3schools.com/sql/sql_insert.asp[^]
 
INSERT INTO table_name (column1, column2, column3,...)
VALUES (value1, value2, value3,...)
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 CPallini 405
1 Sergey Alexandrovich Kryukov 272
2 OriginalGriff 165
3 George Jonsson 159
4 Richard MacCutchan 110
0 OriginalGriff 6,344
1 Sergey Alexandrovich Kryukov 5,890
2 CPallini 5,175
3 George Jonsson 3,559
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 25 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100