我試圖連接到oracle數據庫而不必使用TNS名稱,但它一直給出這個錯誤:{「ORA-12504:TNS:listener was not given在CONNECT_DATA「的SERVICE_NAME}嘗試連接時沒有使用tnsnames連接TNS listner錯誤#
string oradb = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=105.1.12.190)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=OMP1)));User ID=user;Password=pass;";
OracleConnection conn = new OracleConnection(oradb); // C#
conn.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandText = "SELECT cast(Count(*) as varchar(20)) as trig FROM ZDMSN.TRIGGER_TEST";
這裏是什麼在 'TNS名稱' 文件:
OMP1=
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(HOST=105.1.12.193)
(PORT=1521)
)
(CONNECT_DATA=
(SID=OMP1)
)
)