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

3

We are using Installshield to install one of our application.

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

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

We have a problem with package when we install on a windows 8 or windows 2012 server.

We having this error in Installshield, related with the version of ODBC:

[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 that it is related with the ODBC versions (32 bit vs 64 bit) that are both located in here:

C:\Windows\SysWOW64\odbcad32.exe

OR

C:\Windows\System32\odbcad32.exe

To really test this issue, I created a console app that will open and close the odbc connection and log the errors in a text file.

Here's the 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 small tool from my computer which has an oracle server, it works fine. I test it on several other servers and computers that have an oracle instance and it works fine too.

We found out that on a windows server 2012 or on a window 8, the connection could not open.

When I compile my app in x86:

I get this message error which is the same as the one thrown by install shield:

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's 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 in 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 some missing dlls? Where Can I download them?

c#
windows-8
odbc
32bit-64bit
installshield
asked on Stack Overflow Dec 16, 2014 by billybob • edited Dec 17, 2014 by marc_s

1 Answer

0

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 development work, and plan to modify applications that currently use this feature. Instead, use the ODBC driver provided by Oracle."

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

answered on Stack Overflow Jan 14, 2015 by Andrey Belykh

User contributions licensed under CC BY-SA 3.0