Pat
Pat

Reputation: 668

How do I connect my 32 bit app to a 64 bit System DSN?

How do I connect to a 64 bit system DSN from a 32 bit application? I get the error: ERROR [IM014] [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application

OdbcConnection con = new OdbcConnection();
con.ConnectionString = string.Format("DSN={0}", _dsnName); 

I've seen lots of posts where people use 64 bit to connect to 32 is there a way to go from 32 to 64 without redefining your ODBC Connection using the 32 bit app? c:\windows\syswow64\odbcad32.exe

Upvotes: 4

Views: 2281

Answers (2)

OzBob
OzBob

Reputation: 4530

A 'prefer32bit' exe, calling a 64bit dll. Solutions:

  1. CorFlags.exe SampleIntegration.exe /32BITPREF-
  2. Untick 'prefer 32 bit' in VisualStudio
  3. Compile to 64 bit

Upvotes: 1

Kevin
Kevin

Reputation: 4636

If you are able to you should consider compiling your app for Any CPU which will allow it to run as a 64 or 32 bit app depending on what HW it is run on.

For a very good detailed article about bitness differences see Scott Hanselman's blog post about this.

Upvotes: 0

Related Questions