问题
I have a Win32 application that makes ODBC-Connections. We connect using SQLDriverConnect()
which displays a dialog to select the data source. In the x64-Version the Dialog shows and offers 2 different 32 Bit MS ACCESS Drivers. When i select one of these, in the 32 Bit version i would see a open file dialog to select a .mdb file. In the 64 Bit version the call to SQLDriverConnect() at this point returns with -1.
SQLError()
returns: "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"
Is it in general possible to use a 32 Bit ODBC Driver from a 64-Bit executable? Why are these driver shown? As far as i can find there is no 64 Bit MS Access OBDC driver so far. What can i do?
回答1:
You absolutely cannot mix 32bit application and 64bit driver (or vice-versa).
Basically, an ODBC driver is, typically, a dll (windows) or a shared object (linux...) which is loaded by its parent application.
All executables, dlls, etc that share the same process space must be the same bit'ness...
回答2:
In order to "bridge" from a 64bit application to a 32bit ODBC driver you would need to employ an ODBC to ODBC Bridge such as -
http://uda.openlinksw.com/odbc-odbc-mt/
This has a 64bit ODBC client component which connects vis sockets to 32bit server components. The server components bridge to a pre-configured 32bit Access ODBC DSN.
Client component can be either on the local machine or a server machine...
回答3:
Well, I don't know why SQLDriverConnect()
works the way you describe it, but perhaps this Blog post from Microsoft
http://blogs.msdn.com/b/psssql/archive/2010/01/21/how-to-get-a-x64-version-of-jet.aspx
can help you a little bit.
Seems there will be no native 64 bit ODBC driver for MS Access in near future, but those ACE components mentioned there may be an alternative.
回答4:
You can't, but you have the alternative to compile your app in 32bits, and use the 32bit odbc driver. In my case, I use GoLang just change GOARCH environment variable SET GOARCH=386 then compile your project go build and your all set.
来源:https://stackoverflow.com/questions/5634056/can-i-use-a-32-bit-odbc-driver-for-my-64-bit-app