在未安装驱动程序的情况下连接ODBC [英] Connect ODBC without driver installed

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

问题描述

是否可以在未安装系统级驱动程序的情况下进行ODBC连接?我可以只指向包含驱动程序的DLL吗?

Is it possible to make ODBC connection without system-wide driver installed? Can I just point a DLL that contains the driver?

我在32位C ++中使用它,当前在Windows上进行测试,并连接到Firebird数据库.我尝试了以下连接字符串,该字符串不起作用:

I use it in C++, 32bit, currently testing on Windows, and connect to the Firebird Database. I tried following connection string, that doesn't work:

constexpr auto DatabaseConnection =
//"DRIVER=Firebird/InterBase(r) driver;" //this works when driver installed
"UID=SYSDBA;"
"PWD=masterkey;"
"DBNAME=C:\\some\\path\\to\\database\\DB.FDB;"
"Client=C:\\Windows\\System32\\OdbcFb.dll;";

错误消息:[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

推荐答案

Firebird ODBC驱动程序包含应在应用程序内链接的小型静态库(名为OdbcFb.lib).在引擎盖下,它可能预加载了dll,并以某种方式将其注册为新驱动程序. 链接此类库时,有效的连接字符串为:

Firebird ODBC Driver contains small static library (named OdbcFb.lib) that should be linked within the application. Under the hood it probably preloads the dll and registers it as a new driver somehow. When such library is linked, the connection string that works is:

"DRIVER=OdbcFb.dll;UID=SYSDBA;PWD=masterkey;DBNAME=127.0.0.1:C:\\path\\DB.GDB;";

让我惊讶的是,当您省略DRIVER时,它也可以工作,通过使用一些魔术来选择适当的驱动程序:

What surprised me, when you omit DRIVER it also works, choosing apriopriate driver by using some magic:

"UID=SYSDBA;PWD=masterkey;DBNAME=127.0.0.1:C:\\path\\DB.GDB;";

请注意:

  • OdbcFb.dll必须对您的应用程序可见(位于同一目录或系统PATH中)
  • 应该注意选择适当的库体系结构,即32位或64位.
  • the OdbcFb.dll has to be visible for your application (be at the same directory or in system PATH)
  • one should be aware of choosing apriopriate library architecture, namely 32-bit or 64-bit.

这篇关于在未安装驱动程序的情况下连接ODBC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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