Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by marek428 · Jul 11, 2011 at 11:35 PM · stringdatabaseconnection

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

6 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by marek428 · Jul 12, 2011 at 05:29 PM

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

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image raja03 · Mar 01, 2016 at 09:06 AM 1
Share

Hi there. I am getting the following error: OdbcException: ERROR [I$$anonymous$$002] [$$anonymous$$icrosoft][ODBC Driver $$anonymous$$anager] Data source name not found and no default driver specified System.Data.Odbc.OdbcConnection.Open ()

Can you please tell from where you got the $$anonymous$$icrosoft ODBC for Oracle driver?

avatar image puissancex · Sep 05, 2017 at 01:37 PM 0
Share

Hello, i would like to know if you have a link to download the ODBC driver, the one you used because there are a lot...

Cordially

avatar image
0

Answer by marek428 · Jul 12, 2011 at 02:27 AM

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);
             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?
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by ThiagoBruxo · Jul 16, 2012 at 04:08 PM

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

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image marek428 · Jul 17, 2012 at 01:12 AM 0
Share

Try here: http://www.oracle.com/technetwork/database/windows/downloads/index-101290.html

It gives you a lot to download, but it should be under the driver area.

Also, I wound up scrapping my oracle endeavor as there were too many bugs. I basically got it to work with limited features, things maybe better in the new version. Best of luck :)

avatar image TheCircadian · Dec 28, 2020 at 08:35 PM 0
Share

What I often do is go to the NuGet Gallery, and find the NuGet Package for the library. Download that, and change the file type from .nupkg to .zip, and then you can usually find the DLL in one of those subfolders. For the Oracle.DataAccess one, it's in the lib folder.

avatar image
0

Answer by ThiagoBruxo · Jul 16, 2012 at 04:07 PM

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by jeffblumenthal · Jan 12, 2017 at 11:42 AM

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

can Unity connect to Filemaker database? 2 Answers

How to integrate SQL database in game? 1 Answer

Android | online database 2 Answers

Firebase Connection error 0 Answers

connect sqlite3 into unity 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges