Search code examples
c#odbcdenodo

C# connect to System ODBC datasource


The server admin created a 32-bit ODBC system DSN for me that has the database and user credentials in it. I'm struggling now to understand how to connect to that database from my C# code. If I'm using an SSIS connection it goes through without issue, so I know the data they set is correct.

Am I supposed to be using SqlConnection or OleDbConnection to access this now? I've tried both, and no matter what type of connection strings I try it always results in errors. This is connecting to a Denodo instance of that matters for the connection string.


Solution

  • Just put in the DSN name that's been configured:

    using System.Data.Odbc;
    OdbcConnection DbConnection = new OdbcConnection("DSN=SAMPLE_ISAM");
    // Your code here
    DbConnection.Close();
    

    Everything else is the same, the "Connection String" information is all contained in the DSN itself, if properly configured.