Click here to Skip to main content
15,881,516 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:
C++
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
Updated 25-Jan-13 12:15pm
v4

1 solution

This will help with your insert statement,

http://www.w3schools.com/sql/sql_insert.asp[^]

SQL
INSERT INTO table_name (column1, column2, column3,...)
VALUES (value1, value2, value3,...)
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900