在Qt中使用ODBC驱动程序 [英] ODBC driver use in Qt

查看:267
本文介绍了在Qt中使用ODBC驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用读写mdb文件(Ms Access文件),并且在Qt中使用ODBC完全陌生.

I wanted to use read and write mdb file (Ms Access file) and I am completely new in using ODBC in Qt.

所以有人可以帮助我知道我是否需要下载驱动程序,如果可以,我可以从哪里下载?如果您了解连通性,那么将为您提供任何帮助.

So can anyone help me to know whether should i need to download the drivers and if yes then from where can i download ? and if you know about connectivity then any help would be appriciated.

推荐答案

如果您需要使用Qt访问MS Access数据库,则无需(如果我没有记错的话)安装与驱动程序有关的任何内容(应做的一切)已经在那里).

If you need to access an MS Access database with Qt, you don't need (if I'm not mistaken) to install anything regarding drivers (everything should be already there).

您可以使用连接字符串连接到数据库.像这样的东西:

You can connect to a database with a connection string. Something like this :

QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setDatabaseName("Driver={Microsoft Access Driver (*.mdb, *.accdb)};DSN='';DBQ=C:\\path\\to\\mydatabase.mdb");
bool Success = db.open();

这篇关于在Qt中使用ODBC驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆