Can't Connect to Data Source Using ODBC (.Net Core 3.0) RRS feed

  • Question

  • I'm trying to connect to a database via ODBC from my c# project in VS 2019 (.Net Core 3.0). I'm on a 64-bit system, and I believe I have both 32- and 64-bit odbc drivers installed. The problem occurs trying to connect to Access or MySQL databases

    I was able to setup a Data connection in server explorer which uses a data source name of "MS Access Database". When I test the connection, it works fine. Also, I can expand the new connection in server explorer, and I can see all of the tables just fine. I right-click the data connection and choose Modify, I can see the data source name is:

    Dsn=MS Access Database;dbq=C:\Brandeis\BNCConejo_Data.accdb;defaultdir=C:\Brandeis;driverid=25;fil=MS Access;maxbuffersize=2048;pagetimeout=5;uid=admin

    If I'm trying to connect to a MySQL database, I use a known good DSN name called "MySql", which is being used in a production Access application and is working fine to link Access tables.

    Whether I use the Access connection string or the MySql DSN, the connection object is instantiated without error.  Please see the code below.  But when I execute the Connection.Open() method, I get the following error:

    ERROR [IM014] [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application

    Here is a code snippet:

    using (var conn = new OdbcConnection(connectionString))
          // execute code against connection...
       catch (OdbcException ex)
           LastError = "ODBC Error: " + ex.Message;
           return null;

    Some research seems to indicate a mismatch between 64- or 32-bit versions of the ODBC data driver.

    I tried switching Target Platform between "Any CPU", "x86" and "x64", but always get the above error.

    I can't figure out why when setting up a data connection in Server Explorer, the connection tests ok, and after saving I can expand the connection and see the files, but when trying to open the connection in c# code I get that error.

    Can anybody shed some light on this? Thanks...

    Ron Mittelman

    Sunday, June 7, 2020 8:40 PM


All replies

  • Hi,

    Try to create a 64 bit DSN. Windows comes with DSN for 32 bit and 64 Bit.
    You can create both types of DSN.
    Try 64 bit DSN and call Start->ODBCad64. On my Windows it leads to a 64 BIT DSN.

    Compile your Exe with "Target Platform 64bit". Not 32 Bit, Not AnyCPU.
    Regards Alexander

    Sunday, June 7, 2020 9:08 PM
  • Thanks for reply Alexander.

    This is confusing. When I open up the 64-bit ODBC Administrator, it lists MS Access Database and MySql DSN, but both of them show 32-bit under the Platform column.  Also, my version of Access is 32-bit, and my working MySql DSN is also 32-bit.

    Are you saying that if I can install the 64-bit data sources, then running the 64-bit ODBC Administrator, it will then say 64-bit under the Platform column?

    Ron Mittelman

    Sunday, June 7, 2020 10:16 PM
  • Hi,

    Thanks for posting here.

    Since this forum is for discussing the Windows Desktop Development, but this thread may be not related it. I will redirect this case to the correct forum, thanks for understanding.

    Best Regards,


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, June 8, 2020 7:19 AM
  • Also try asking for help over here.





    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows Server] Datacenter Management

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.

    Monday, June 8, 2020 11:42 AM
  • Thanks a ton for sharing this to us!
    Tuesday, June 9, 2020 11:33 AM
  • Solved this issue by completely uninstalling 32-bit Office and reinstalling 64-bit office.

    Ron Mittelman

    Wednesday, June 10, 2020 11:36 PM
  • Glad to hear the issue is sorted.



    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows Server] Datacenter Management

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.

    Wednesday, June 10, 2020 11:58 PM