QT14 how to save data in sqlite database with pushbutton
来源:互联网 发布:央视直播软件下载apk 编辑:程序博客网 时间:2024/06/05 22:09
1. reedit the employinfo window like
2.reedit the employinfo.cpp as
#include "employeeinfo.h"#include "ui_employeeinfo.h"#include "login.h"#include <QMessageBox>EmployeeInfo::EmployeeInfo(QWidget *parent) : QDialog(parent), ui(new Ui::EmployeeInfo){ ui->setupUi(this); if(!login::connOpen()) { ui->label_sec_status->setText("Failed to open the database") ; } else { ui->label_sec_status->setText("Connected...") ; }}EmployeeInfo::~EmployeeInfo(){ delete ui;}void EmployeeInfo::on_pushButton_clicked(){ QString eid, name, surname, age; eid = ui->txt_eid->text(); name =ui->txt_name->text(); surname = ui->txt_surname->text(); age = ui->txt_age->text(); if(!login::connOpen()) { qDebug() << "Failed to open the database"; return ; } QSqlQuery qry; QString stmt = "insert into employeeinfo (eid,name,surname,age) values('"+ eid +"','"+ name +"','"+ surname +"','"+ age +"')"; qry.prepare(stmt); if( qry.exec()) { QMessageBox::information(this, tr("Save"), tr("Saved")); login::connClose(); } else { QMessageBox::critical(this, tr("Error"), qry.lastError().text()); }}
0 0
- QT14 how to save data in sqlite database with pushbutton
- Qt15 Update a data from Sqlite database with pushbutton
- QT16 delete data from sqlite database with pushbutton
- QT18 how to link QListView with sqlite Database values
- QT19 How to link QComboBox with sqlite Database values
- how to use a SQLite database in a standalone program with an HTML interface and VBScript as the programming language
- How to access sqlite database
- How to seek CEDB Database in wince5 with CEDB_SEEK_VALUEFIRSTEQUAL Parameter?
- How to save data in ASCII format in ADS for use in MATLAB
- ABAP - REPORT - How to add user-pushbutton in selection screen
- user master page with asp:FormParameter , save only blank data to Database MSAccess
- How to read and save Images in a Sql Server Database using ADO.NET and C#
- How to get started with data science in containers
- How to use the System Restore API to save and to restore system data in Visual C++
- How to save or get Images through Database.
- how to use Properties and File to Save Data
- How to select the data type in SQLserver database such as varchar, nvarchar
- use stack to initial a treeview with the data in a database
- 英语总结系列(十五):别样的三月
- 初识PHP之一个注释埋下的坑!
- CSS学习(二十二)-flexbox模型之三
- VC++ 绘制简单电子元件
- 基于LTPA的WAS SSO基础配置
- QT14 how to save data in sqlite database with pushbutton
- 110. Balanced Binary Tree
- odm teamserver与定制portal sso过程中遇到的Request Headers Referer属性安全性校验问题
- Bash玩转脚本1之自己的脚本安装程序
- 红帽虚拟化RHEV-PXE批量安装RHEV-H
- 第60课:使用Java和Scala在IDE中实战RDD和DataFrame动态转换操作学习笔记
- Google Test(GTest)使用方法和源码解析——Listener技术分析和应用
- printf函数bug
- BeanFactoryPostProcessor和BeanPostProcessor区别和应用场景