Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server DSN-Less ODBC Specify 32 bit Driver

I'm working with an older application that I recently updated to .NET 4.5. The application has been using DSN ODBC connections. However, in the case of the application, it is accessed from a single location on a network drive, so it doesn't make sense to require a DSN, and it will ease deployment and updates to use a DSN-less connection string in place. I'm doing a basic string as such:

Driver={SQL Server}; Server=; Database=; UID=; PWD=

The issue I have is that the application is compiled as 32 bit, but may be used on a 32 bit or 64 bit machine. On 64 bit machines I get this error:

The specified DSN contains an architecture mismatch between the Driver and Application

Which essentially means it's trying to use the 64 bit driver for the 32 bit application. That's easy enough to deal with except the driver name for SQL Server appears to be the same for 32 and 64 bit. So how can I specify only the 32 bit driver in the connection string?

like image 986
Jarrod Christman Avatar asked Nov 08 '17 22:11

Jarrod Christman


People also ask

How do I change ODBC driver to 32-bit or 64-bit?

If you build and then run an application as a 32-bit application on a 64-bit operating system, you must create the ODBC data source by using the ODBC Administrator tool in %windir%\SysWOW64\odbcad32 .exe. To indicate the type of DSN, you can add '_32' to the 32-bit user DSNs and '_64' to the 64-bit user DSNs.

How can I tell if my ODBC driver is 32 or 64-bit?

Answer. On Windows 32-bit systems, the ODBC driver is 32-bit if the nsqlodbc. dll file is located in the C:\WINDOWS\system32 directory. Both 32-bit and 64-bit programs can run on 64-bit Windows OS.

Can I can connect a 32-bit application to a 64-bit ODBC driver?

Yes, you can connect a 32-bit application to a 64-bit ODBC driver by using the ODBC-ODBC Bridge. Without the ODBC-ODBC Bridge, a 32-bit application cannot connect to a 64-bit ODBC driver. 32-bit applications must be linked against 32-bit libraries.


1 Answers

"To manage a data source that connects to a 32-bit driver under 64-bit platform, use c:\windows\sysWOW64\odbcad32.exe. To manage a data source that connects to a 64-bit driver, use c:\windows\system32\odbcad32.exe. In Administrative Tools on a 64-bit Windows 8 operating system, there are icons for both the 32-bit and 64-bit ODBC Data Source Administrator dialog box. Read more"

If you use the 64-bit odbcad32.exe to configure or remove a DSN that connects to a 32-bit driver, you will receive the following error message:

The specified DSN contains an architecture mismatch between the Driver and Application

To resolve this error, use the 32-bit odbcad32.exe to configure or remove the DSN.

References

  • The specified DSN contains an architecture mismatch between the Driver and Application
  • Managing Data Sources

Side Note: make sure that all references Copy Local property is set to True, even the System assemblies. I think that the issue may be from the assemblies location saved in GAC, so when copying the assemblies locally it may fix that

like image 193
Hadi Avatar answered Oct 27 '22 07:10

Hadi