当前位置:网站首页>Qt连接神通数据库
Qt连接神通数据库
2022-06-30 08:33:00 【艾米莉亚糖】
1.先去神通数据库官网下载"神通数据库"系统。

2.下载完毕后里面有一个"神通数据库-数据库快速入门.pdf"的操作文档。

3.按照操作文档进行安装。

4.安装完毕后查看神通数据库的服务是否启动,没启动的话请手动改为启动。

5.可以通过odbc数据源功能查看安装的神通数据库驱动。

6.安装完毕后程序目录下会有个"神通数据库-数据库开发手册"

7. 我们找到 "使用 SQLDriverConnect 连接" ,里面还有其他方式连接,具体请自行查看 。

8.Qt连接的代码如下:
QSqlDatabase KQProduct::getQSqlDatabaseConn()
{
QSqlDatabase database = QSqlDatabase::database("KqMobileExChange"); //连接名称
if(database.isOpen())
return database;
database = QSqlDatabase::addDatabase("QODBC","KqMobileExChange");
const QString strName(QString("DRIVER={OSCAR ODBC DRIVER};SERVER=%1;UID=%2;PWD=%3;DATABASE=%4;Port=%5")
.arg(m_sServer) //服务地址
.arg(m_sUser) //用户名称
.arg(m_sPwd) //用户密码
.arg(m_sDatabase) //数据库实例
.arg(m_nPort)); //端口号
database.setDatabaseName(strName);
if (!database.open())
{
QMessageBox::critical(0, QString::fromLocal8Bit("数据库连接错误"),database.lastError().text());
}
return database;
}

边栏推荐
- 【NVMe2.0b 14-5】Firmware Download/Commit command
- Tidb v6.0.0 (DMR): initial test of cache table - tidb Book rush
- [untitled]
- QT event cycle
- 2021-02-19
- Sword finger offer II 076 The kth largest number in the array (use heap to solve TOPK problem)
- 【NVMe2.0b 14-2】Create/Delete Queue
- Detectron2 source code reading 4-- registrar construction model
- [untitled]
- Cesium learning notes (VI) particle system
猜你喜欢

Axure制作菜单栏效果

Flink Exception -- No ExecutorFactory found to execute the application

Swagger use

TiDB v6.0.0 (DMR) :缓存表初试丨TiDB Book Rush

Detectron2 source code reading 3-- encapsulating dataset with mapper

Sword finger offer II 076 The kth largest number in the array (use heap to solve TOPK problem)

Gilbert Strang's course notes on linear algebra - Lesson 2

Codeworks 5 questions per day (1700 for each) - the third day

Enhance the add / delete operation of for loop & iterator delete collection elements

Oracle expansion table space installed in docker
随机推荐
【NVMe2.0b 14-6】Format NVM、Keep Alive、Lockdown command
mysql基础入门 day3 动力节点[老杜]课堂笔记
Dlib library blink
Vite project require syntax compatibility problem solving require is not defined
Sword finger offer II 074 Merge interval (sort, array)
Redis design and Implementation (VII) | publish & subscribe
文件上传 upload 组件 on-success 事件,添加自定义参数
Axure make menu bar effect
[untitled]
Wsl2 using GPU for deep learning
Markdown支持的emoji图标
vim 从嫌弃到依赖(21)——跨文件搜索
2021-04-29
Wechat applet reports errors using vant web app
Codeworks 5 questions per day (1700 for each) - the third day
【NVMe2.0b 14-4】Directive Send/Receive command
Redis design and Implementation (III) | interaction between server and client (event IO model)
Map,String,Json之間轉換
Enter the URL in the browser and display it on the page
Experiment 6 examination