02-26-2014 03:23 PM
Are there any guidelines for how to connect to an external Oracle database in a Unity script?
I'm familiar with using SqlClient objects and System.DataSets to connect to SQL Server databases, but this is the first time I'm trying to work with an Oracle database. I know I don't want to use System.Data.OracleClient since it's deprecated.
My ultimate goal is to have a Unity script that will run in a workflow timer. Do I need to have an Oracle client installed on the AppServer and/or on the server running the Timer Service? I'm trying to come up with a solution that would require a minimal amount of Oracle software installed on our various AppServers and Timer Service servers. This is a new project which needs to retrieve data from (and update data to) an Oracle database. Other than that, our OnBase installation doesn't use Oracle at all.
I installed the 'Oracle Developer Tools for Visual Studio' on my machine, and created a Windows Form which successfully connects to an Oracle database (with hard-coded user id, password, and datasource port, service name, and host, so as to not use the tnsnames.ora file) and retrieves data from a table. So that was one small success. Next step was to try to duplicate this in a Unity script. Our OnBase Configuration module is on a server, so, instead of installing 'Oracle Developer Tools for Visual Studio' on the server, I copied the 'Oracle.DataAccess.dll' to the server and used the Unity 'Import Assembly Wizard' to import it. I can now reference 'Oracle.DataAccess' in my Unity project, my code compiles. I basically copied and pasted my VS code into my Unity project, with its OracleConnection, OracleCommand, and OracleDataReader. But I get a runtime exception "The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception." with an InnerException "Oracle.DataAccess.Client.OracleException The provider is not compatible with the version of Oracle client".
As I'm wading through various Google search results, it appear I may need to have an Oracle client installed on the server, or perhaps some additional Oracle dll's. But before continuing I thought I'd ask the advice of anyone who may have done this before.
Thank you in advance for any help!
Rob
02-03-2015 10:22 AM
02-03-2015 01:20 PM
Hank,
If I understand your question correctly, it sounds like you need to add a reference to ODP.NET to your project. I would recommend checking out the documentation at http://www.oracle.com/technetwork/topics/dotnet/index-085163.html. ; Specifically the "Oracle By Example for Visual Studio" for your version of VS. There are also code samples you may find useful.
Also, since this isn't strictly speaking a Unity API issue, you might want to check out Stack Overflow. You will find a lot of information on there about ODP.NET.
Thanks,
Ulrik
02-03-2015 07:05 PM
02-04-2015 10:02 AM
Hank,
Most of my experience is with using the Unity API in custom .NET applications, so I may not be the best person to address your question.
That being said, I believe the OP's solution was to use the Oracle library instead of the functionality you are trying to leverage. The resources I mentioned will help you with using that library.
You might want to start a separate thread if you want to try to avoid that approach. Sorry that I couldn't provide a more direct answer to your question.
Thanks,
Ulrik
02-04-2015 10:29 AM
This is a sample C# Unity script snippet for a Connection String named "OracleSample"
if(connection == null)
{ connection = ConfigurationHelper.GetConnection(
app.Configuration, "OracleSample");
connection.Open();
}
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.