How do I connect to an Oracle Database?

I am not certain of what connection string I should be using and if I have to copy specific dlls into my project?

Any help would be appreciated, thanks.

Ok, I found the answer - posting to help anyone else that may encounter this problem (give me some good karma if it helps :slight_smile:

               using System.Data.Odbc;  
               OdbcConnection cn;
			   OdbcCommand cmd;

			   cn= new OdbcConnection("Driver={Microsoft ODBC for Oracle};Server=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=" + dbServer + ")(PORT="+ dbPort + "))(CONNECT_DATA=(SID=" + dbSID + ")));Uid=" + dbUsername + ";Pwd=" + dbPassword + ";");

			   cmd=new OdbcCommand(yourQuery,cn);

				OdbcDataReader rData = cmd.ExecuteReader();
				while (rData.Read()){
					Debug.Log("row" +rData[0] + " " + rData[1] );

There were a number of problems I ran into with this implementation

  1. I had to use the ODBC driver for Oracle as the Oracle and MS drivers did not work as I showed above (EDIT: below now as this one got up-voted). I am sure someone can get this to work, but I am not that good of a programmer.
  2. The next problem is that Unity will crash as DataTable.Load does not work with the Oracle ODBC driver (although it works on the same DLL with the XLS implementation - odd no?). So that is why I have the “while (rData.Read())” as I am planning on populating the DataTable manually myself. It is working for me so far, although I am sure there is a far, far better way of doing this.
  3. Any questions, please let me know.

Ok, I stumbled around a bit and got somewhat further. I did the following:

  1. I found a copy of Oracle.DataAccess.dll on my computer and copied it to my project

  2. I added using Oracle.DataAccess.Client; to my imports

  3. Then I added the following code:

    		OracleConnection oCon = new OracleConnection(con);
    	OracleCommand oCmd = new OracleCommand();
    	oCmd.Connection = oCon;
    	oCmd.CommandText = yourQuery;
    	oCmd.CommandType = CommandType.Text;
    	OracleDataReader dr = oCmd.ExecuteReader();

And it compiles! But unfortunately I received this error for my troubles (it fails on the oCon.Open();):

NotImplementedException: The requested feature is not implemented.
System.EnterpriseServices.ContextUtil.get_IsInTransaction ()
Oracle.DataAccess.Client.ConnectionDispenser.Open (Oracle.DataAccess.Client.OpoConCtx opoConCtx)
Oracle.DataAccess.Client.OracleConnection.Open ()
(wrapper remoting-invoke-with-check) Oracle.DataAccess.Client.OracleConnection:Open ()
ReadExcel.readData (System.String source) (at Assets/Scripts/ReadExcel.cs:359)
ReadExcel.OnGUI () (at Assets/Scripts/ReadExcel.cs:216)

Does this mean Unity/Mono does not support Oracle? Or am I doing something else wrong that is above my pay grade?

People, where I can find the Oracle.DataAccess.dll and Oracle.DataAccess.Client to download?

People, where I can find the Oracle.DataAccess.dll and Oracle.DataAccess.Client to download?

I am having problems hitting an 11g instance using 5.5.0f3. My suspicion is the current set of drivers go up to 10g. Therefore I went 3rd party. I got working quickly. Note, I DO NOT work for them.


EDIT: Yeah I was super proud. It really works. But fucking unity will notice the “sharade” when building. I do not get why this has to be such a big problem. So basically if your goal is playing from the editor…here you go:

I finally figured it out after many days and also in a probably nicer way than you. I really hope it helps because I was already going to change to a diferent DB alltogether because there is no info.

EDIT: I also created a youtube video: How to connect Oracle DB to Unity (Still will not build -.-) - YouTube

  1. Since unity 2018 I think you can go to the player setting and change the Project-Player-Settings. There under “Other Settings” you will find Scripting Runtime Version. This value can now be set to 4.x.
    You want to do that because to use the modern Oracle drivers (Managed Driver) you need at least framework 4.0.
  2. Since the whole unity 4.0 is apparently somewhat experimental it still doesnt work with the Oracle.ManagedDataAccess directly. Dunno why…basically it checks something in the Oracle dlls, says they are broken and will not let you use them. Also it will not let you use NuGet packages.
    However what you can do (what I just now did) and what will work is: Write your own Oracle Access dll just directly from VS2017 (for example). Just a standard dll and you need to import the Oracle managed ODP. If you search for “oracle” in nuget its the first thing in the list (1.7 million DLs). Import this and write your dll like this (just an example to test the functionality for me):


using Oracle.ManagedDataAccess.Client;

namespace OracleUnityConnector {
public class Class1 {
static OracleConnection oraConn;

	public static void MakeOraConn(string ip, string port, string serviceName) {
		oraConn = new OracleConnection("Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=" + ip + ")(PORT=" + port + "))(CONNECT_DATA=(SERVICE_NAME=" + serviceName + ")));User Id = SUPERSTRAT; Password = SUPERSTRAT;");

	public static void CloseOraConn() {
		if (oraConn != null) {
			oraConn = null;

	public static void ExecuteSQLNoReturnVal(string command) {
		OracleCommand oraCom = new OracleCommand(command, oraConn);


For some reason it won’t let me format it correctly here.

3.Now all you have to do is to build this dll and then copy the resulting dll to your unity Assets (also you will have to copy locally Oracle:ManagedDataAccess.dll and also copy that right next to it).
Do not forget to (in Unity itself) navigate to the path and uncheck any loading for any purpose of the Oracle.Mana… dll because unity will not understand it. Only your dll should load this one.

I tested this. It works. In case it doesnt for you please ask me here and I will help as good as I can.