使用oracle.ManagedDataAccess.Client错误ora-12550

时间:2016-07-22 07:32:20

标签: c# oracle connection oracle-manageddataaccess

当我执行我的代码时,我有以下错误:

ORA-12550 : The supplied connect descriptor contains illegal syntax.

我检查了http://www.orafaq.com/wiki/Tnsnames.ora上是否有正确的语法,似乎没什么不好,所以我不知道 这可能是错误。

public static OracleConnection GetDBConnection(string host, int port, String sid, String user, string password)
    {
        string connString = "Data Source=(DESCRIPTION=(ADRESS=(PROTOCOL=tcp)(HOST="+host+")(PORT="+port+"))(CONNECT_DATA=(SERVICE_NAME="+sid+")));User Id="+user+";Password="+password;
        OracleConnection conn = new OracleConnection();
        conn.ConnectionString = connString;
        return conn;
    }

1 个答案:

答案 0 :(得分:3)

首先,“ADDRESS”有两倍“D”。 此外,ADDRESS是ADDRESS_LIST的一部分,请尝试     (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = your_host)(PORT = your_port) ) )