简体   繁体   中英

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 Oracle 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

Do you have the Oracle client software installed? Can you connect using SQL+ on the client machine or using the server explorer?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM