当前位置:网站首页>【Qt】第十章:数据库
【Qt】第十章:数据库
2022-06-23 17:32:00 【亚东同学】
第十章:数据库
- 主要:
创建连接:会创建了一个QSqIDatabase类 的实例,只有调用open()函数后该连接才可以被使用。
QSqlQuery类 提供了一个接口,用于执行SQL语句和浏览查询的结果集。要执行一个SQL语句,则只需要简单地创建一个QSqlQuery对象,然后调用QSqlQuery : : ex-ec()函数即可,例如:
QSqlQuery query;
query.exec( "select * from student");
- QTSQL模块:

可以通过QSqIDatabase::drivers()方法来获取当前的sql模快中支持哪些数据库。 - 当创建多个连接时,应指定连接名称,不能默认
QSqlDatabase db1 = QSqIDatabase::addDatabase("QSQLITE",connect1);
QSqlDatabase db2 = QSqlDatabase::addDatabase("QSQLITE",connect2);
查询结果集:
seek(int n) : query指向结果集的第n条记录。指定当前的位置
first() : query指向结果集的第一条记录。
last() : query指向结果集的最后一条记录。
next() : query指向下一条记录,每执行一次该函数,便指向相邻的下一条记录。previous():指向上一条记录,每执行一次该函数,便指向相邻的上一条记录。record():获得现在指向的记录。
value(int n):获得属性的值。其中n表示你查询的第n个属性
query.at():l获取query所指向的记录在结果集中的编号query.record().indexOf(“name”):ll返回"name"的列号
query.record().count():l获取每条记录中属性(即列)的个数
Record.field(n):ll获取当前记录的第n个字段
- 核心:
增 删 查 改
边栏推荐
- What does the science and technology interactive sand table gain popularity by virtue of
- 暂停更新公告—行走的皮卡丘
- leetcode刷题:哈希表02 (两个数组的交集)
- QML type: Loader
- esp8266-01s 不能连接华为路由器解决方法
- [esp8266 - 01s] obtenir la météo, Ville, heure de Beijing
- STM32(八)------- PWM输出
- 2022年T电梯修理考试题库及模拟考试
- How to make good use of daily time to review efficiently?
- Imeta | Nannong shenqirong team released microbial network analysis and visualization R package ggclusternet
猜你喜欢

Will programmers become very professional in the future?

Self training multi sequence learning with transformer for weakly supervised video animation

Wiley- Open Science Joint Symposium of the documentation and information center of the Chinese Academy of Sciences, lecture 2: open access journal selection and paper submission

Stepping mode of research control motor

Video anomaly detection data set (shanghaitech)

深入理解 padding

2022年T电梯修理考试题库及模拟考试

Leetcode: hash table 02 (intersection of two arrays)

如何利用好每天的时间高效复习?

渗透测试基础,初识渗透测试
随机推荐
csdn涨薪秘籍之Jenkins集成allure测试报告全套教程
leetcode刷题:哈希表01 (有效的字母异位词)
Shell脚本编写
Redis Cluster
计算机学院改考后,网络空间安全学院也改考了!南京理工大学计算机考研
[win10 vs2019 opencv4.6 configuration reference]
JS array to remove duplicate data
Wechat applet reports an error [app.json file content error] app json: app. JSON not found
五星认证!知道创宇通过中国信通院内容审核服务系统评测
Paper reading (55):dynamic multi robot task allocation under uncertainty and temporary constraints
Latex编译成功但是无法输出到PDF
实用电路分析3
QT based graphics rendering system documentation + project source code and executable exe files + system instructions
Customer service system building tutorial_ Installation and use mode under the pagoda panel_ Docking with official account_ Support app/h5 multi tenant operation
实现领域驱动设计 - 使用ABP框架 - 通用准则
Video anomaly detection data set (shanghaitech)
【剑指Offer】46. 把数字翻译成字符串
第十三届蓝桥杯单片机国赛真题
2022年T电梯修理考试题库及模拟考试
『忘了再学』Shell流程控制 — 39、特殊流程控制语句