OracleConnection.Open is throwing ORA-12541 TNS no listener

后端 未结 2 2150
旧时难觅i
旧时难觅i 2021-02-14 09:55

So I am connecting to an external server through C#. I just installed Oracle 11g client on my machine from here: http://www.oracle.com/technetwork/database/wind

2条回答
  •  走了就别回头了
    2021-02-14 10:26

    You can do this a couple of ways: Using your TNSNames file the data source should specify the TNSHosts entry name (the bit before the first "=" from the tnsnames.ora), not the host name:

    connection.ConnectionString = "Data Source=TestingConnect;Persist Security Info=True;" + "User ID=tesName;Password=test"; 
    

    Or you can put the entire TNS entry in the connection string like so:

    connection.ConnectionString = "Data Source=(DESCRIPTION = " +
        "(ADDRESS = (PROTOCOL = TCP)(HOST = TestHostName.us.local)(PORT = 1523))" +
        "(CONNECT_DATA =" + 
        "(SERVER = DEDICATED)" + 
        "(SERVICE_NAME = TEST))" + 
        ");Persist Security Info=True;User ID=tesName;Password=test"; 
    

提交回复
热议问题