connectionstring属性尚未初始化的问题!!!真的找不出原因了?
代码如下:
public class DbObject
{
private static string ConnectionString;
private OleDbConnection Conn;
private OleDbCommand Comm;
private OleDbDataReader Reader;
protected OleDbDataAdapter Adapter;
protected DataSet Ds;
public DbObject()
{
ConnectionString=ConfigurationManager.ConnectionStrings[ "ConnString "].ConnectionString+HttpContext.Current.Server.MapPath(ConfigurationManager.ConnectionStrings[ "ConnData "].ConnectionString);
Conn = new OleDbConnection(ConnectionString);
Comm = new OleDbCommand();
Comm.Connection = Conn;
//Adapter = new OleDbDataAdapter();
//Adapter.SelectCommand.Connection = Conn;
Ds = new DataSet();
}
/// <summary>
/// 释放连接及内存资源
/// </summary>
protected void Dispose()
{
if (Conn != null)
{
Conn.Close();
Conn.Dispose();
}
if (Comm != null)
{
Comm.Dispose();
}
//if (Ds != null)
//{
// Ds.Dispose();
//}
}
/// <summary>
/// 执行Sql语句,无返回值
/// </summary>
/// <param name= "sql "> sql语句 </param>
protected void ExecuteNonQuery(string sql)
{
Conn.Open();
Comm.CommandText = sql;
Comm.ExecuteNonQuery();