当前位置:网站首页>QT connects two qslite databases and reports an error qsqlquery:: exec: database not open
QT connects two qslite databases and reports an error qsqlquery:: exec: database not open
2022-07-29 07:41:00 【CSDN Q & A】
QT Connect two qslite An error is reported when there is a data connection problem in the database QSqlQuery::exec: database not open
Two databases are two different interfaces , This is the code of one of the databases
Main function program
QSqlDatabase m_db=QSqlDatabase::addDatabase("QSQLITE","material_connect");
m_db.setDatabaseName("E:\Damage-assessment\software\QT\GUI\GUI4.0\gui1.0\build-gui-Desktop_Qt_5_14_2_MSVC2017_64bit-Release\mental_material.db");
if(m_db.open()) { qDebug()<<"open success1"; } else { qDebug()<<"open failed1"; } QSqlQueryModel *model=new QSqlQueryModel(this); QString sql; sql="select name as full name ,density as density , shear_modulus as shear modulus ,yield_stress as Yield stress , maximum_yield_stress as Maximum yield stress , melting_temperature as Melting temperature from mental_material"; model->setQuery(sql,m_db); ui->display->setModel(model); Click the slot function of the button
void material::on_show_pushButton_clicked()
{
QSqlQueryModel *model=new QSqlQueryModel;
QString sql;
sql="select name as full name ,density as density , shear_modulus as shear modulus ,yield_stress as Yield stress , maximum_yield_stress as Maximum yield stress , melting_temperature as Melting temperature from mental_material";
model->setQuery(sql,m_db); ui->display->setModel(model);}
Operation results and error reporting contents
This is the picture after running

But click the display button , The database is gone

Report errors QSqlQuery::exec: database not open
边栏推荐
- Strongly connected component
- 新生代公链再攻「不可能三角」
- webapi接口文件下载时跨域问题
- [summer daily question] Luogu p6336 [coci2007-2008 2] bijele
- [summer daily question] Luogu P6500 [coci2010-2011 3] zbroj
- How much data can a single MySQL table store at most?
- [WPF] realize language switching through dynamic / static resources
- Chaos and future of domestic digital collections
- @RequestMapping 用法详解
- STM32 operation w25q256 w25q16 SPI flash
猜你喜欢

2-unified return class dto object

Halcon installation and testing in vs2017, DLL configuration in vs2017

MySQL uses date_ FORMAT(date,'%Y-%m')

Cs61abc sharing session (VI) detailed explanation of program input and output - standard input and output, file, device, EOF, command line parameters

10 practical uses of NFT

Segger's hardware anomaly analysis

NLP introduction + practice: Chapter 5: using the API in pytorch to realize linear regression

How does MySQL convert rows to columns?

Monitor the bottom button of page scrolling position positioning (including the solution that page initialization positioning does not take effect on mouse sliding)

零数科技深度参与信通院隐私计算金融场景标准制定
随机推荐
Embroidery of little D
性能更佳、使用更简单的懒加载IntersectionObserverEntry(观察者)
2022 Shenzhen Cup Title A: get rid of "scream effect" and "echo room effect" and get out of the "information cocoon room"
Dilworth 定理
国内数字藏品的乱象与未来
[summer daily question] Luogu p7760 [coci2016-2017 5] tuna
NLP introduction + practice: Chapter 5: using the API in pytorch to realize linear regression
Segger's hardware anomaly analysis
OA项目之会议通知(查询&是否参会&反馈详情)
【暑期每日一题】洛谷 P4413 [COCI2006-2007#2] R2
State machine DP (simple version)
Better performance and simpler lazy loading of intersectionobserverentry (observer)
Amazon cloud assistant applet is coming!
MySQL 45讲 | 08 事务到底是隔离的还是不隔离的?
For the application challenge of smart city, shengteng AI gives a new solution
Prometheus and grafana
电子元器件贸易企业如何借助ERP系统,解决仓库管理难题?
[100 cases of unity practice] the single choice multiple choice judgment questions of unity universal question answering system are all common
写点dp
信用卡购物积分