是否可以在未安装系统级驱动程序的情况下进行ODBC连接?我可以只指向包含驱动程序的DLL吗?
我在32位C ++中使用它,当前在Windows上进行测试,并连接到Firebird数据库。我尝试了以下连接字符串,该字符串不起作用:
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
答案 0 :(得分:0)
是的,可以通过完全指定连接字符串来与未注册的ODBC驱动程序建立无DSN的连接。
正确安装驱动程序时使用的这一行-
MacBook:exampleCom example$ ssh -v git@example.com
OpenSSH_7.9p1, LibreSSL 2.7.3
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug1: Connecting to example.com port 22.
debug1: Connection established.
debug1: identity file /Users/example/.ssh/id_rsa type 0
debug1: identity file /Users/example/.ssh/id_rsa-cert type -1
debug1: identity file /Users/example/.ssh/id_dsa type -1
debug1: identity file /Users/example/.ssh/id_dsa-cert type -1
debug1: identity file /Users/example/.ssh/id_ecdsa type -1
debug1: identity file /Users/example/.ssh/id_ecdsa-cert type -1
debug1: identity file /Users/example/.ssh/id_ed25519 type -1
debug1: identity file /Users/example/.ssh/id_ed25519-cert type -1
debug1: identity file /Users/example/.ssh/id_xmss type -1
debug1: identity file /Users/example/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.9
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.7p1 Debian-5+deb8u7
debug1: match: OpenSSH_6.7p1 Debian-5+deb8u7 pat OpenSSH* compat 0x04000000
debug1: Authenticating to example.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:J7RwXfLgnsuMlJNo4M0LotFN+XAi6q7ak2tlzJ6ECTI
debug1: Host 'example.com' is known and matches the ECDSA host key.
debug1: Found key in /Users/example/.ssh/known_hosts:2
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: Will attempt key: /Users/example/.ssh/id_rsa RSA SHA256:ItsLqWD1sVwEdkp3xIffO0PcAGZx2NdqhIuScZrzjqw agent
debug1: Will attempt key: /Users/example/.ssh/id_rsa RSA SHA256:lShiocfZXbNH9Cp3+w+aY6XDcSVDDTyBHC52L5Qc3N0
debug1: Will attempt key: /Users/example/.ssh/id_dsa
debug1: Will attempt key: /Users/example/.ssh/id_ecdsa
debug1: Will attempt key: /Users/example/.ssh/id_ed25519
debug1: Will attempt key: /Users/example/.ssh/id_xmss
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering public key: /Users/example/.ssh/id_rsa RSA SHA256:ItsLqWD1sVwEdkp3xIffO0PcAGZx2NdqhIuScZrzjqw agent
debug1: Authentications that can continue: publickey,password
debug1: Offering public key: /Users/example/.ssh/id_rsa RSA SHA256:lShiocfZXbNH9Cp3+w+aY6XDcSVDDTyBHC52L5Qc3N0
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /Users/example/.ssh/id_dsa
debug1: Trying private key: /Users/example/.ssh/id_ecdsa
debug1: Trying private key: /Users/example/.ssh/id_ed25519
debug1: Trying private key: /Users/example/.ssh/id_xmss
debug1: Next authentication method: password
git@example.com's password:
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
git@example.com's password:
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
git@example.com's password:
debug1: Authentications that can continue: publickey,password
debug1: No more authentication methods to try.
git@example.com: Permission denied (publickey,password).
Have also tried https access and the following error:
MacBook:MyGitRepo jeffb$ git push origin_https https://example.com:4438/root/MyGitRepo.git
error: src refspec https://example.com does not match any.
error: failed to push some refs to 'https://example.com:4438/root/MyGitRepo.git'
-实际上应该是这样,以按名称引用驱动程序-
"DRIVER=Firebird/InterBase(r) driver;"
-应更改为此-
"DRIVER={Firebird/InterBase(r) driver};"
如果"DRIVER=C:\\Windows\\System32\\OdbcFb.dll;"
设置不正确(包括包含%PATH%
的目录),并且/或者如果FB驱动程序未在MDAC驱动程序管理器中注册,则必须出现以下情况:指向odbcfb.dll
的特定于FB的client
关键字,在这种情况下,您不需要任何对odbcfb.dll
的引用。
阅读creating DSNs和DNSless connections的驱动程序自己的文档,您可能会受益...
答案 1 :(得分:0)
Firebird ODBC驱动程序包含小型静态库(名为OdbcFb.lib
),应在应用程序内进行链接。在引擎盖下,它可能预加载了dll,并以某种方式将其注册为新驱动程序。
链接此类库时,有效的连接字符串为:
"DRIVER=OdbcFb.dll;UID=SYSDBA;PWD=masterkey;DBNAME=127.0.0.1:C:\\path\\DB.GDB;";
让我感到惊讶的是,当您省略DRIVER时,它也可以通过使用一些魔术来选择适当的驱动程序:
"UID=SYSDBA;PWD=masterkey;DBNAME=127.0.0.1:C:\\path\\DB.GDB;";
请注意:
OdbcFb.dll
必须对您的应用程序可见(位于同一目录或系统PATH中)