Error when using odbc on some platforms (32 bit vs 64 bit)

We are using Installshield to install one of our applications.

One of the steps requires you to enter connection strings for the Oracle instance.

In Installshield, we use ODBC to open oracle connection and run some scripts on the database.

We have a problem with a package when installing on a Windows 8 or Windows 2012 server.

We have this error in Installshield related to ODBC version:

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified Source: Microsoft OLE DB Provider for ODBC Drivers SQL State: IM002 Native Error: 0 

      

We knew it was related to the ODBC versions (32 bit and 64 bit) that are found here:

C:\Windows\SysWOW64\odbcad32.exe

      

OR

C:\Windows\System32\odbcad32.exe

      

To actually test this issue, I created a console application that will open and close an odbc connection and log errors in a text file.

Here's a small sample:

using System.Data.Odbc;
using System.IO;

static void Main(string[] args)
{
    TextWriter tw = new StreamWriter("Errors.txt");
    Console.WriteLine("Enter the Server Name:");
    var Server = Console.ReadLine();
    Console.WriteLine("Enter the Instance Name:");
    var instancename = Console.ReadLine();
    try
    {
        OdbcConnection DbConnection = new OdbcConnection("Driver= {Microsoft ODBC for Oracle};Server=" + Server + ":1521/" + instancename + ";Uid=system;Pwd=manager;");
        DbConnection.Open();
        DbConnection.Close();
        tw.WriteLine("No errors");
    }
    catch (Exception e)
    {
        tw.WriteLine(e);
    }
    finally
    {
        tw.Close();
    }
}

      

If I run this little tool from my oracle server computer it works fine. I am testing it on several other servers and computers with an oracle instance and it works fine.

We found out that on the Windows 2012 server or in window 8, the connection could not be opened.

When I compile my application to x86:

I am getting an error that is the same as the one selected by the installation screen:

System.Data.Odbc.OdbcException (0x80131937): ERROR [NA000] [Microsoft][ODBC driver for Oracle][Oracle]Error while trying to retrieve text for error ORA-01019
ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver SQLSetConnectAttr failed
ERROR [01000] [Microsoft][ODBC Driver Manager] The driver doesn't support the version of ODBC behavior that the application requested (see SQLSetEnvAttr).
   at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode)
   at System.Data.Odbc.OdbcConnectionHandle..ctor(OdbcConnection connection, OdbcConnectionString constr, OdbcEnvironmentHandle environmentHandle)
   at System.Data.Odbc.OdbcConnectionOpen..ctor(OdbcConnection outerConnection, OdbcConnectionString connectionOptions)
   at System.Data.Odbc.OdbcConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   at System.Data.Odbc.OdbcConnection.Open()

      

When I compile it to x64 I get a different error message:

System.Data.Odbc.OdbcException (0x80131937): ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
   at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode)
   at System.Data.Odbc.OdbcConnectionHandle..ctor(OdbcConnection connection, OdbcConnectionString constr, OdbcEnvironmentHandle environmentHandle)
   at System.Data.Odbc.OdbcConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   at System.Data.Odbc.OdbcConnection.Open()

      

Any hints?

Do I have any missing DLLs? Where can I download them?

+3


source to share


1 answer


According to this http://msdn.microsoft.com/en-us/library/ms713590%28v=vs.85%29.aspx "This feature will be removed in a future version of Windows. Avoid using this feature in new designs, and plan to modify applications that currently use this feature. Use the ODBC driver provided by Oracle instead. "



My recommendation is to use ODP.Net (they have 32 and 64 bit drivers and can be installed at the same time) http://www.oracle.com/technetwork/topics/dotnet/downloads/index.html

0


source







All Articles