Hello everyone,
If you’re running a x64 variant of Windows, you might bump into the following problem whilst developing programs that work with databases:
You can’t seem to establish a connection to the database.
This usually means that there aren’ t 64-bit drivers available for the database engine you’re using (For example, MS Access)
The solution for your problem is easy:
- If you are developing a .NET application in Visual Studio:
- For Visual Basic projects, go to the Compile tab and press the Advanced Compile Options button.
In the dialog change the Target CPU to x86 - For Visual C# projects, go to the Build tab and change Platform Target to x86
- For Visual Basic projects, go to the Compile tab and press the Advanced Compile Options button.
- If you are developing a Java application and you’re using DSN:
- Add a System DSN using the odbcad32.exe located in C:\Windows\SysWOW64\odbcad32.exe and NOT the one located in C:\Windows\System32\odbcad32.exe (The one that opens when you go to Control Panel > Administrative Tools > Data Sources (ODBC))
For some database engines (such as SQL Server) there are 64-bit drivers available (and usually automaticly installed).
Therefor you can develop 64-bit applications for SQL Server, but most other database engines only work with 32-bit drivers.
That’s pretty much the basic solution to the problem.
If you have any questions, please ask them and I’ll do my best to help you 🙂
– Dirk
P.S.: Incase you’re wondering how you have to work with DSN files in .NET, here is a small code snippet to establish a connection using a System DSN with ODBC:
Dim oCon As New System.Data.Odbc.OdbcConnection("DSN=myDSN")
I don’t really consider Access as a Database. It’s a desktop product, and you need MS drivers installed if you want to distribute it with your application.
I would suggest SQL Server Compact, which is file based (no need for an instance like with the full SQL Server).
And it works on 32 and 64 bit (if you install the proper drivers).
IF you install the correct drivers then yes, you can use SQL CE in a 64-bit application.
By default, those drivers aren’t installed and for those who wish to avoid the hassle of searching for / downloading of the proper drivers, they can easily change the build options 😉
Well I do prefer having the possiblity to install 64-bit drivers than having no drivers at all :+