简体   繁体   中英

Connect to remote oracle database from .net application using c#

I am developing one application that uses remote 'Oracle' database. but I am facing the issue in connecting to that database. I have followed following steps to connect to the 'Oracle database by the name 'rudresh' which is situated in a server with IP address '10.10.10.10'(wrong IP as I can't share exact IP).

string oradb = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.10.10.10)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=rudresh)));User Id=system;Password=system_db;";
OracleConnection conn = new OracleConnection(oradb);
try
{
    conn.Open();
    string sql = "SELECT * FROM X96TUSER"; // C#
    OracleCommand cmd = new OracleCommand(sql, conn);
    cmd.CommandType = CommandType.Text;
    OracleDataReader dr = cmd.ExecuteReader(); // C#
    dr.Read();
    string test = dr.GetString(0).ToString();
}

but actually while opening the connection using conn.Open() its throwing exception 'System.Data.OracleClient requires Oracle client software version 8.1.7 or greater' but my oracle version is 11g. please, anyone, let me know what I am doing wrong or do I need to do any changes in the server?

This can be a security issue. Check your permissions in the oracle client folder.

Another possible cause (IIRC) is having the wrong oracle client library (ie having the 64bit version on a 32bit set-up).

(of course, that's assuming you have the Oracle Client installed)

I think oracle client alone doesn't work standalone. Have you downloaded the ODAC for Windows ?. While installing try to specify different home folders for different installations, eg. 32bithome or 64bithome. First you can try 32bithome(even on 64bit machine and then try to create 64bithome if it doesn't work.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM