使用Qt c ++ gui将CODE插入SQLite [英] Insert CODE using Qt c++gui to SQLite
本文介绍了使用Qt c ++ gui将CODE插入SQLite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只需要帮助我的项目。我正在使用Qt creator for Mobile symbian OS。
我想知道什么是最好的插入命令,以便用户将输入数据保存到SQLite中。
我有这样的代码:
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
推荐答案
这将有助于您的插入声明,
http://www.w3schools.com/sql/sql_insert.asp [ ^ ]
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,...)
这篇关于使用Qt c ++ gui将CODE插入SQLite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文