Connect to a remote Oracle 11g server using OracleClient of .NET 2.0
I have to connect to a Oracle server on the network using a .NET / C# (Winform) application. I am trying to use System.Data.OracleClient
but in vain.
Here are the details I can possibly think of (that might help someone reading this question):
Platform: Visual Studio 2005 / .NET 2.0 with C# on Windows Vista Home Premium
Library: System.Data.OracleClient
Server: Oracle 11g (located on the same LAN)
Please note that I don't have O开发者_如何学JAVAracle installed locally and I have hunted every discussion forum possible for help - but most of them assume local Oracle installation!
Here is my connection string:
"User Id=TSUSER;Password=ts12TS;Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=
MyServerIP)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL)));
"
And I get this error:
OCIEnvCreate failed with return code -1 but error message text was not available.
Stack trace:
at System.Data.OracleClient.OciHandle..ctor(OciHandle parentHandle, HTYPE handleType, MODE ocimode, HANDLEFLAG handleflags)
at System.Data.OracleClient.OracleInternalConnection.OpenOnLocalTransaction(String userName, String password, String serverName, Boolean integratedSecurity, Boolean unicode, Boolean omitOracleConnectionName)
at System.Data.OracleClient.OracleInternalConnection..ctor(OracleConnectionString connectionOptions)
at System.Data.OracleClient.OracleConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.OracleClient.OracleConnection.Open()
at DGKit.Util.DataUtil.Generate() in D:\SVNRoot\sandbox\DGDev\Util\DataUtil.cs:line 68
Working since 2 years on an ASP.NET 4.0 application that connects to Oracle, I still have to say that I hate it :-)
The Oracle .NET drivers are just awfully buggy. After tring several different versions (x86, x84, beta, stable, etc.) I finally found a solution that works.
I also experienced that the Oracle provider that ships (shipped?) with .NET itself was not usable for me, so only the .NET drivers/libraries directly from the Oracle site worked.
In addition, when having SQL Developer (the Java application) successfully running, it was by no means an indicator whether the .NET stuff works, too. It seems they are completely unrelated.
Do you have the Oracle client software installed? Can you connect using SQL+ on the client machine or using the server explorer?
精彩评论