当我尝试执行以下操作时,我具有connectionString OracleConnection
:ConnectionString.Open();
我收到错误消息:对象引用未设置为对象的实例。
代码:
private static OracleConnection _connectionString;
private static OracleConnection ConnectionString
{
get
{
if (_connectionString == null)
{
_connectionString = new OracleConnection(ConfigurationManager.ConnectionStrings["DB"].ConnectionString);
}
return _connectionString;
}
}
ConnectionString.Open();
在webConfig中:
<add name="DB" providerName="System.Data.OracleClient" connectionString="data source=test;Persist Security Info=true;user id=db;password=db"/>