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.
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
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);
cn.Open();
Debug.Log("Connected");
OdbcDataReader rData = cmd.ExecuteReader();
while (rData.Read()){
Debug.Log("row" +rData[0] + " " + rData[1] );
}
Debug.Log(rData.FieldCount);
rData.Close();
cn.Close();
There were a number of problems I ran into with this implementation
Ok, I stumbled around a bit and got somewhat further. I did the following:
I found a copy of Oracle.DataAccess.dll on my computer and copied it to my project
I added using Oracle.DataAccess.Client; to my imports
Then I added the following code:
OracleConnection oCon = new OracleConnection(con);
oCon.Open();
OracleCommand oCmd = new OracleCommand();
oCmd.Connection = oCon;
oCmd.CommandText = yourQuery;
oCmd.CommandType = CommandType.Text;
OracleDataReader dr = oCmd.ExecuteReader();
dr.Read();
oCon.Close();
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 https://www.devart.com/dotconnect/ working quickly. Note, I DO NOT work for them.
HTH
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
"
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;");
oraConn.Open();
}
public static void CloseOraConn() {
if (oraConn != null) {
oraConn.Close();
oraConn.Dispose();
oraConn = null;
}
}
public static void ExecuteSQLNoReturnVal(string command) {
OracleCommand oraCom = new OracleCommand(command, oraConn);
oraCom.ExecuteNonQuery();
}
}
}
"
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.