4

I have been looking for this for long time , I have developed Windows Forms App using C # that have to connect Oracle database, this app will be used on many PCs using windows XP and windows 7 After long research i have found that i need to use OBP.net for oracle access but problem is i cannot install oracle client on every PC, However i found work around in CodePorject Exampleto download 5 DLL files to do the same job

OCI Instant Client Data Shared Library
    oraociicus10.dll (Basic-Lite version)
    oraociei10.dll (Basic version)
Client Code Library
    oci.dll
Security Library
    orannzsbb10.dll
OCCI Library
    oraocci10.dll

But when i release the app it dosent connect to Oracle Database Please help how i can have my Windows Forms app connecting Oracle Database with no oracle client installed PC and if this is achievable through the above DLLS how i can do that ?

EDIT:

DataTable dt = new DataTable();
OracleConnection Oracle_connection = new OracleConnection();
Oracle_connection.ConnectionString = con;
Oracle_connection.Open();

got connection timeout, in Oracle_connection.Open(); in debugging mode and I dont use TNSNAMES.ORA as my connection string is as

Data Source=(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.20.2.54)(PORT = 1521))(CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = PRD))) ;User Id=catering;Password=catering;"`

Tried to publish the code it worked on Windows 7 PC but didnt work on Windows XP System.TypeInitializationException: The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception. ---> Oracle.DataAccess.Client.OracleException The provider is not compatible with the version of Oracle client at Oracle.DataAccess.Client.OracleInit.Initialize()

Dunno if it's windows related or some DLLs are missing

Mo Patel
  • 2,191
  • 4
  • 21
  • 34
Ahmed Samy
  • 707
  • 1
  • 10
  • 27
  • 1
    "It doesn't connect to Oracle Database" are you getting an exception (which one?) The CodeProject example has some troubleshooting tips, did you read those? – C.Evenhuis Jan 07 '13 at 12:29
  • Do you have an appropriate TNSNAMES.ORA file in the same directory or do you have the appropriate connection string? – Pow-Ian Jan 07 '13 at 17:10
  • Thank you for your reply, edit my question already – Ahmed Samy Jan 08 '13 at 08:57

3 Answers3

2

There is also fully managed .net connector aka ODP.NET Managed Driver:

I've tested it on Windows 8 and Windows XP SP3 with .NET 4.0 framework installed - all working as expected. For deploying, only 1 dll is needed (Oracle.ManagedDataAccess.dll) which weights 6 MB (in comparison with instant client lite which was almost 40 MB).

UPDATE: Probably the best way to use managed oracle driver is via NuGet (ODP.NET @ nuget)

Stritof
  • 720
  • 6
  • 10
0

ODP.net is fussy about mixing version numbers. The error message:

System.TypeInitializationException: The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception. ---> Oracle.DataAccess.Client.OracleException The provider is not compatible with the version of Oracle client at Oracle.DataAccess.Client.OracleInit.Initialize()

indicates that its picking up the wrong client DLL version somewhere. When I did some development with Oracle and Visual C# 2010 I downloaded the ODP.NET libraries from:

http://www.oracle.com/technetwork/developer-tools/visual-studio/downloads/index.html

I then took the correct version for the version of Oracle I would be working with and used those DLLs in my project. I'm not sure what the restrictions are in redistribution though.

0

Look at this thread: The provider is not compatible with the version of Oracle client

The DLLs listed there did the job for me (All in the same directory as the exe).

Community
  • 1
  • 1
Fritz
  • 304
  • 2
  • 6