部署 Qt ODBC 应用程序
我的应用程序以这种方式使用 Qt SQL
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb)};DBQ="+QDir::currentPath()+"/database.mdb");
,其余所有操作都是使用 QSqlRelationalTableModel 完成的。
现在部署阶段已经到来,应用程序在安装了 Qt (4.6.3) 的系统上完美运行,但在另一个干净系统上,加载数据库时出现此错误
"Driver not loaded"
我知道这有问题与复制 ODBC 插件有关...但只是将 qsqlodbc4.dll
复制到应用程序目录并且
qApp->addLibraryPath(QDir::currentPath());
不起作用!
解决方案是什么?
注意:该应用程序未链接到驱动程序 DLL,它使用 Qt 插件机制。
My application uses Qt SQL this way
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb)};DBQ="+QDir::currentPath()+"/database.mdb");
and all the rest is done using QSqlRelationalTableModel
.
Now that deployment stage has come, the application works perfectly on the system where Qt (4.6.3) is installed , but on another clean system, there is this error while loading the database
"Driver not loaded"
I know this has something to do with copying the ODBC plugins... but simply copying qsqlodbc4.dll
to the app dir and
qApp->addLibraryPath(QDir::currentPath());
does not work!!
What is the solution to this?
Note: The app is not linked to the driver DLL, it uses Qt plugin mechanism.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建与安装 qt 的电脑上相同的目录结构。
your.app.dir/plugins/your.plugin.folder (即 your.plugin.folder 是 sqldrivers)
将您的插件复制到 your.app.dir/plugins/your.plugin_folder
然后添加此代码
我希望这会有所帮助。
Create this directory structure same as it was on pc having qt installation.
your.app.dir/plugins/your.plugin.folder (i.e your.plugin.folder is sqldrivers)
Copy your plugin under your.app.dir/plugins/your.plugin_folder
Then add this code
I hope this helps.