2

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

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;
    }
4

1 回答 1

3

首先,“ADDRESS”有双“D”。ADDRESS 也是 ADDRESS_LIST 的一部分,所以试试 (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = your_host)(PORT = your_port) ) )

于 2016-07-22T07:55:41.173 回答