.NET C# vs2008 连接Oracle
连接代码:
OracleConnection conn=null;
OracleCommand cmd=null;
string mConn = "Data Source=DB1;User ID=scott;Password=tiger;"; //连接数据库
conn=new OracleConnection(mConn);
报错如下:
System.Data.OracleClient.OracleException: ORA-12154: TNS: 无法解析指定的连接标识符
在 System.Data.OracleClient.OracleException.Check(OciErrorHandle errorHandle, Int32 rc)
在 System.Data.OracleClient.OracleInternalConnection.OpenOnLocalTransaction(String userName, String password, String serverName, Boolean integratedSecurity, Boolean unicode, Boolean omitOracleConnectionName)
在 System.Data.OracleClient.OracleInternalConnection..ctor(OracleConnectionString connectionOptions)
在 System.Data.OracleClient.OracleConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
在 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
在 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
在 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
在 System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
在 System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
在 System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
在 System.Data.OracleClient.OracleConnection.Open()
但是PLSQL能连上,请教下是什么问题啊?C#新手啊
[解决办法]