C# oracle ASP.NET:TNS问题
我正在尝试使用ASP.NET/C#连接到我的数据库oracle 这是我的密码:C# oracle ASP.NET:TNS问题,c#,asp.net,oracle11g,tns,C#,Asp.net,Oracle11g,Tns,我正在尝试使用ASP.NET/C#连接到我的数据库oracle 这是我的密码: OracleConnection connection = new OracleConnection(); connection.ConnectionString = @"Data Source=ORACLEDB;User id=me;Password=xxxx;"; try { connection.Open(); } catch (Exception ex) { Console.WriteLine(
OracleConnection connection = new OracleConnection();
connection.ConnectionString = @"Data Source=ORACLEDB;User id=me;Password=xxxx;";
try
{
connection.Open();
}
catch (Exception ex)
{
Console.WriteLine("Exception occurs when connecting to DB : " + ex.Message + ex.StackTrace);
}
下面是我得到的错误:
ORA-12154: TNS : the identifier could not be solved
这是我的TNSNAMES.ora:
ORACLEDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = myComputer.myDomain)(PORT = 1521))
(CONNECT_DATA =
(SERVICE_NAME = ORACLEDB)
)
)
我在win2k3服务器R2上工作
Oracle位于同一台服务器上。是甲骨文11g
当我做tnsping时,我会得到:
EZCONNECT adapter used to resolved the alias
Tentative de contact de (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTOCOL=TCP)(HOST=169.254.216.123)(PORT=1521)))
OK (20 msec)
这是我的听众。奥拉:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = C:\app\Administrator\product\11.2.0\dbhome_1)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:C:\app\Administrator\product\11.2.0\dbhome_1\bin\oraclr11.dll")
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = myComputer.myDomain)(PORT = 1521))
)
)
尝试使用TNSPING诊断您的问题。它是在oracle home/bin目录中找到的实用程序
尝试使用TNSPING诊断您的问题。它是在oracle home/bin目录中找到的实用程序
什么是EZConnect适配器?也许TNSPing和您的代码使用了不同的驱动程序
尝试在代码的连接字符串中使用数据库的IP地址。这可能会向您显示问题的原因 什么是EZConnect适配器?也许TNSPing和您的代码使用了不同的驱动程序
尝试在代码的连接字符串中使用数据库的IP地址。这可能会向您显示问题的原因 当我尝试在连接字符串中使用myComputer.myDomain作为数据源时,它会给出错误代码
ORA-12504:TNS:侦听器processus未在CONNECT\u数据中获取服务\u名称
Idk EZConnect是什么:-)
命令tnsping localhost给出以下命令:
C:\app\Administrator\product\11.2.0\dbhome_1\network\admin\sqlnet.ora
Adaptateur TNSNAMES utilisé pour la résolution de l'alias
Tentative de contact de (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = myComputer.myDomain)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = ORACLEDB)))
OK (20 msec)
也许这会有帮助:当我尝试使用SQL Plus连接我的数据库时,它工作得很好
非常感谢您的帮助。当我尝试在连接字符串中使用myComputer.myDomain作为数据源时,它会给出错误代码
ORA-12504:TNS:侦听器processus未在CONNECT\u数据中获取服务\u名称
Idk EZConnect是什么:-)
命令tnsping localhost给出以下命令:
C:\app\Administrator\product\11.2.0\dbhome_1\network\admin\sqlnet.ora
Adaptateur TNSNAMES utilisé pour la résolution de l'alias
Tentative de contact de (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = myComputer.myDomain)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = ORACLEDB)))
OK (20 msec)
也许这会有帮助:当我尝试使用SQL Plus连接我的数据库时,它工作得很好
非常感谢您的帮助。将字符串连接放入web.config:
<connectionStrings>
<add name="OracleDatabase"
connectionString="Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME= ORACLEDB)));User Id= me;Password= xxx;Persist Security Info=True;"
providerName="System.Data.OracleClient" />
</connectionStrings>
connection.ConnectionString = ConfigurationManager.ConnectionStrings["OracleDatabase"].ConnectionString;
将字符串连接放在web.config中:
<connectionStrings>
<add name="OracleDatabase"
connectionString="Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME= ORACLEDB)));User Id= me;Password= xxx;Persist Security Info=True;"
providerName="System.Data.OracleClient" />
</connectionStrings>
connection.ConnectionString = ConfigurationManager.ConnectionStrings["OracleDatabase"].ConnectionString;