当前位置:网站首页>【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个字段
- 核心:
增 删 查 改
边栏推荐
- 知道创宇:内容向善,AI+人工赋能
- Thesis reading (53):universal advantageous perturbations
- 如何利用好每天的时间高效复习?
- VNC Viewer方式的远程连接树莓派
- 2022 t elevator repair test question bank and simulation test
- Reading papers (51):integration of a holonic organizational control architecture and multiobjective
- 【ESP8266-01s】獲取天氣,城市,北京時間
- 论文阅读 (56):Mutli-features Predction of Protein Translational Modification Sites (任务)
- Prevent users from submitting repeatedly in the uniapp project
- Stepping mode of research control motor
猜你喜欢

科技互动沙盘是凭借什么收获人气的

论文阅读 (56):Mutli-features Predction of Protein Translational Modification Sites (任务)
![[unity] instructions for beginners of textanimator plug-in](/img/aa/a406c70a28931ac138e65787a0aabd.png)
[unity] instructions for beginners of textanimator plug-in

Customer service system building tutorial_ Installation and use mode under the pagoda panel_ Docking with official account_ Support app/h5 multi tenant operation

Redis 集群

STM32(八)------- PWM输出

QML类型:Loader

【 Huazhong University of Science and technology】 Data Sharing for retest of the initial Examination

org. apache. ibatis. binding. BindingException: Invalid bound statement (not found):...

建立自己的网站(13)
随机推荐
6 steps to teach you financial data mining preprocessing
如何利用好每天的时间高效复习?
CSDN salary increase secret script: Jenkins integrated allure test report complete tutorial
QML类型:Loader
Sword finger offer II 092 Flip character / Sword finger offer II 093 Longest Fibonacci sequence
基于QT实现的图形学绘制系统 文档+项目源码及可执行EXE文件+系统使用说明书
Rancher2.6全新Monitoring快速入门
Will programmers become very professional in the future?
Leetcode: hash table 07 (sum of three numbers)
2022 t elevator repair test question bank and simulation test
leetcode刷题:哈希表04 (两数之和)
Counter attack and defense (1): counter sample generation in image domain
uniapp项目中防止用户重复提交
实现领域驱动设计 - 使用ABP框架 - 通用准则
论文阅读 (56):Mutli-features Predction of Protein Translational Modification Sites (任务)
MySQL -- classic interview questions
Paper reading (50):a novel matrix game with payoffs of maximal belt structure
【剑指Offer】45. 把数组排成最小的数
随机过程——马尔科夫链
Paper reading (55):dynamic multi robot task allocation under uncertainty and temporary constraints