找不到类型或命名空间名称“IDisposabl”(是否缺少 using 指令或程序集引用?)
错误1找不到类型或命名空间名称“IDisposabl”(是否缺少using指令或程序集引用?)F:\源码中心\ASPX\chaye\chaye\App_Code\data...
错误 1 找不到类型或命名空间名称“IDisposabl”(是否缺少 using 指令或程序集引用?) F:\源码中心\ASPX\chaye\chaye\App_Code\data.cs 16 19 F:\...\chaye\
源码是:
using System;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
/// <summary>
/// data 的摘要说明
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShoudBeDisposable")]
//public class data
public class data:IDisposabl
{
public System.Data.OleDb.OleDbConnection con = new System.Data.OleDb.OleDbConnection();
public System.Data.OleDb.OleDbCommand com = new System.Data.OleDb.OleDbCommand();
public System.Data.OleDb.OleDbDataReader reader;
public System.Data.OleDb.OleDbDataAdapter ada;
public System.Data.DataSet DS = new DataSet();
public static int pagesize = 20;
public static int imagepagesize = 20;
public bool IsClose = true;//指示当前对象是否关闭
public string Error = "";
public data()//初始化连结 及 命令连结
{
Init();
}
~data()//释放所有资源
{
Dispose();
}
public void Dispose()
{
if (!IsClose)
{
try
{
con.Close();
}
catch
{ }
if (ada != null)
ada.Dispose();
DS.Dispose();
if (reader != null)
reader.Dispose();
if (ada != null)
ada.Dispose();
com.Dispose();
con.Dispose();
IsClose = true;
}
}
public void Init()
{
if (IsClose)
{
con.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["constr"];
con.Open();
com.CommandTimeout = 30;
com.Connection = con;
IsClose = false;
}
} 展开
源码是:
using System;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
/// <summary>
/// data 的摘要说明
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShoudBeDisposable")]
//public class data
public class data:IDisposabl
{
public System.Data.OleDb.OleDbConnection con = new System.Data.OleDb.OleDbConnection();
public System.Data.OleDb.OleDbCommand com = new System.Data.OleDb.OleDbCommand();
public System.Data.OleDb.OleDbDataReader reader;
public System.Data.OleDb.OleDbDataAdapter ada;
public System.Data.DataSet DS = new DataSet();
public static int pagesize = 20;
public static int imagepagesize = 20;
public bool IsClose = true;//指示当前对象是否关闭
public string Error = "";
public data()//初始化连结 及 命令连结
{
Init();
}
~data()//释放所有资源
{
Dispose();
}
public void Dispose()
{
if (!IsClose)
{
try
{
con.Close();
}
catch
{ }
if (ada != null)
ada.Dispose();
DS.Dispose();
if (reader != null)
reader.Dispose();
if (ada != null)
ada.Dispose();
com.Dispose();
con.Dispose();
IsClose = true;
}
}
public void Init()
{
if (IsClose)
{
con.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["constr"];
con.Open();
com.CommandTimeout = 30;
com.Connection = con;
IsClose = false;
}
} 展开
5个回答
展开全部
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
/// <summary>
/// data 的摘要说明
/// </summary>
public class data
{
public System.Data.OleDb.OleDbConnection con = new System.Data.OleDb.OleDbConnection();
public System.Data.OleDb.OleDbCommand com = new System.Data.OleDb.OleDbCommand();
public System.Data.OleDb.OleDbDataReader reader;
public System.Data.OleDb.OleDbDataAdapter ada;
public System.Data.DataSet DS=new DataSet();
public static int pagesize = 20;
public static int imagepagesize = 20;
public bool IsClose=true;//指示当前对象是否关闭
public string Error = "";
public data()//初始化连结 及 命令连结
{
Init();
}
~data()//释放所有资源
{
Dispose();
}
public void Dispose()
{
if (!IsClose)
{
try
{
con.Close();
}
catch
{ }
if (ada != null)
ada.Dispose();
DS.Dispose();
if (reader != null)
reader.Dispose();
if (ada != null)
ada.Dispose();
com.Dispose();
con.Dispose();
IsClose = true;
}
}
public void Init()
{
if (IsClose)
{
con.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["constr"];
con.Open();
com.CommandTimeout = 30;
com.Connection = con;
IsClose = false;
}
}
public bool ExeDel(string table, string id)
{
if (reader != null && !reader.IsClosed)
reader.Close();
com.CommandText = string.Format("Delete from {0} where ID={1}",table,id);
FormatComstr();
com.ExecuteNonQuery();
return true;
}
public bool ExeCheck(string table, string id,int check)
{
try
{
if (reader != null && !reader.IsClosed)
reader.Close();
com.CommandText = string.Format("Update {0} Set Checked={2} where id={1}", table, id, check);
FormatComstr();
com.ExecuteNonQuery();
return true;
}
catch
{
return false;
}
}
public bool ExeReadOnce(string table, string FieldName,object FieldValue,bool IsNeed)
{
try
{
if (reader != null && !reader.IsClosed)
reader.Close();
com.CommandText = string.Format("Update {0} Set ReadCount=ReadCount+1 where {1}={3}{2}{3}", table, FieldName, FieldValue, IsNeed == true ? "'" : "");
FormatComstr();
com.ExecuteNonQuery();
return true;
}
catch
{
return false;
}
}
public bool ExeCom(string comstr)
{
try
{
if (reader != null && !reader.IsClosed)
reader.Close();
com.CommandText = comstr;
FormatComstr();
com.ExecuteNonQuery();
return true;
}
catch(System.Exception errors)
{
Error = errors.Message;
return false;
}
}
public System.Data.OleDb.OleDbDataReader ExeReader(string comstr)//返回阅读器
{
//try
//{
if (reader!=null&&!reader.IsClosed)
reader.Close();
com.CommandText = comstr;
FormatComstr();
reader=com.ExecuteReader();
return reader;
//}
//catch
//{
//return null;
//}
}
public object ReadSingle(string table, string field, string id)//返回阅读器
{
object re = "";
com.CommandText = string.Format("select {0} from {1} where id={2}", field, table, id);
FormatComstr();
reader = com.ExecuteReader();
if (reader.Read())
{
re = reader[field];
}
else
{
re = "";
}
reader.Close();
return re;
}
public object ReadSingle(string table, string field, string wherefield,string id)//返回阅读器
{
// try
// {
com.CommandText = string.Format("select {0} from {1} where {3} like '{2}'", field, table, id, wherefield);
FormatComstr();
reader = com.ExecuteReader();
if (reader.Read())
{
return reader[field];
}
else
{
return null;
}
/*
}
catch
{
return null;
}*/
}
public int ExeCount(string Comstr)//返回Count
{
// try
// {
if (reader != null && !reader.IsClosed)
reader.Close();
com.CommandText = Comstr;
FormatComstr();
return int.Parse(com.ExecuteScalar().ToString());
/*
}
catch
{
return null;
}*/
}
public bool ListData(string comstr, System.Web.UI.WebControls.GridView DG, int page)//填充网格数据表 起始页为 1
{
//try
//{
if (reader != null && !reader.IsClosed)
reader.Close();
com.CommandText = comstr;
FormatComstr();
ada = new System.Data.OleDb.OleDbDataAdapter(com);
DS.Clear();
ada.Fill(DS, DG.PageSize * (page - 1), pagesize, "temptable");
DG.DataSource = DS.Tables["temptable"];
DG.DataBind();
DS.Dispose();
return true;
//}
//catch
//{
//return false;
//}
}
public bool ListData(string comstr, System.Web.UI.WebControls.GridView DG, int ownpagesize,int page)//填充网格数据表 起始页为 1
{
//try
//{
if (reader != null && !reader.IsClosed)
reader.Close();
com.CommandText = comstr;
FormatComstr();
ada = new System.Data.OleDb.OleDbDataAdapter(com);
DS.Clear();
ada.Fill(DS, DG.PageSize * (page - 1), ownpagesize, "temptable");
DG.DataSource = DS.Tables["temptable"];
DG.DataBind();
DS.Dispose();
return true;
//}
//catch
//{
//return false;
//}
}
public bool ListData(string comstr, System.Web.UI.WebControls.GridView DG)//填充网格数据表 无起始页
{
//try
//{
if (reader != null && !reader.IsClosed)
reader.Close();
com.CommandText = comstr;
FormatComstr();
ada = new System.Data.OleDb.OleDbDataAdapter(com);
DS.Clear();
ada.Fill(DS,"temptable");
DG.DataSource = DS.Tables["temptable"];
DG.DataBind();
DS.Dispose();
return true;
// }
//catch
//{
// return false;
//}
}
public bool ListData(string comstr, System.Web.UI.WebControls.DataList DG, int page,int PageSize)//填充列表数据表 起始页为 1
{
//try
//{
if (reader != null && !reader.IsClosed)
reader.Close();
com.CommandText = comstr;
FormatComstr();
ada = new System.Data.OleDb.OleDbDataAdapter(com);
DS.Clear();
ada.Fill(DS, PageSize * (page - 1), PageSize, "temptable");
DG.DataSource = DS.Tables["temptable"];
DG.DataBind();
DS.Dispose();
return true;
//}
//catch
//{
//return false;
//}
}
public bool isChildRange(string RangeStr)
{
return false;
}
public void FormatComstr()
{
com.CommandText.Trim();
com.CommandText = com.CommandText.Replace(" "," ").ToLower();
com.CommandText = com.CommandText.Replace("where and", "where ");
com.CommandText = com.CommandText.Replace("and and", "and");
}
}
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
/// <summary>
/// data 的摘要说明
/// </summary>
public class data
{
public System.Data.OleDb.OleDbConnection con = new System.Data.OleDb.OleDbConnection();
public System.Data.OleDb.OleDbCommand com = new System.Data.OleDb.OleDbCommand();
public System.Data.OleDb.OleDbDataReader reader;
public System.Data.OleDb.OleDbDataAdapter ada;
public System.Data.DataSet DS=new DataSet();
public static int pagesize = 20;
public static int imagepagesize = 20;
public bool IsClose=true;//指示当前对象是否关闭
public string Error = "";
public data()//初始化连结 及 命令连结
{
Init();
}
~data()//释放所有资源
{
Dispose();
}
public void Dispose()
{
if (!IsClose)
{
try
{
con.Close();
}
catch
{ }
if (ada != null)
ada.Dispose();
DS.Dispose();
if (reader != null)
reader.Dispose();
if (ada != null)
ada.Dispose();
com.Dispose();
con.Dispose();
IsClose = true;
}
}
public void Init()
{
if (IsClose)
{
con.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["constr"];
con.Open();
com.CommandTimeout = 30;
com.Connection = con;
IsClose = false;
}
}
public bool ExeDel(string table, string id)
{
if (reader != null && !reader.IsClosed)
reader.Close();
com.CommandText = string.Format("Delete from {0} where ID={1}",table,id);
FormatComstr();
com.ExecuteNonQuery();
return true;
}
public bool ExeCheck(string table, string id,int check)
{
try
{
if (reader != null && !reader.IsClosed)
reader.Close();
com.CommandText = string.Format("Update {0} Set Checked={2} where id={1}", table, id, check);
FormatComstr();
com.ExecuteNonQuery();
return true;
}
catch
{
return false;
}
}
public bool ExeReadOnce(string table, string FieldName,object FieldValue,bool IsNeed)
{
try
{
if (reader != null && !reader.IsClosed)
reader.Close();
com.CommandText = string.Format("Update {0} Set ReadCount=ReadCount+1 where {1}={3}{2}{3}", table, FieldName, FieldValue, IsNeed == true ? "'" : "");
FormatComstr();
com.ExecuteNonQuery();
return true;
}
catch
{
return false;
}
}
public bool ExeCom(string comstr)
{
try
{
if (reader != null && !reader.IsClosed)
reader.Close();
com.CommandText = comstr;
FormatComstr();
com.ExecuteNonQuery();
return true;
}
catch(System.Exception errors)
{
Error = errors.Message;
return false;
}
}
public System.Data.OleDb.OleDbDataReader ExeReader(string comstr)//返回阅读器
{
//try
//{
if (reader!=null&&!reader.IsClosed)
reader.Close();
com.CommandText = comstr;
FormatComstr();
reader=com.ExecuteReader();
return reader;
//}
//catch
//{
//return null;
//}
}
public object ReadSingle(string table, string field, string id)//返回阅读器
{
object re = "";
com.CommandText = string.Format("select {0} from {1} where id={2}", field, table, id);
FormatComstr();
reader = com.ExecuteReader();
if (reader.Read())
{
re = reader[field];
}
else
{
re = "";
}
reader.Close();
return re;
}
public object ReadSingle(string table, string field, string wherefield,string id)//返回阅读器
{
// try
// {
com.CommandText = string.Format("select {0} from {1} where {3} like '{2}'", field, table, id, wherefield);
FormatComstr();
reader = com.ExecuteReader();
if (reader.Read())
{
return reader[field];
}
else
{
return null;
}
/*
}
catch
{
return null;
}*/
}
public int ExeCount(string Comstr)//返回Count
{
// try
// {
if (reader != null && !reader.IsClosed)
reader.Close();
com.CommandText = Comstr;
FormatComstr();
return int.Parse(com.ExecuteScalar().ToString());
/*
}
catch
{
return null;
}*/
}
public bool ListData(string comstr, System.Web.UI.WebControls.GridView DG, int page)//填充网格数据表 起始页为 1
{
//try
//{
if (reader != null && !reader.IsClosed)
reader.Close();
com.CommandText = comstr;
FormatComstr();
ada = new System.Data.OleDb.OleDbDataAdapter(com);
DS.Clear();
ada.Fill(DS, DG.PageSize * (page - 1), pagesize, "temptable");
DG.DataSource = DS.Tables["temptable"];
DG.DataBind();
DS.Dispose();
return true;
//}
//catch
//{
//return false;
//}
}
public bool ListData(string comstr, System.Web.UI.WebControls.GridView DG, int ownpagesize,int page)//填充网格数据表 起始页为 1
{
//try
//{
if (reader != null && !reader.IsClosed)
reader.Close();
com.CommandText = comstr;
FormatComstr();
ada = new System.Data.OleDb.OleDbDataAdapter(com);
DS.Clear();
ada.Fill(DS, DG.PageSize * (page - 1), ownpagesize, "temptable");
DG.DataSource = DS.Tables["temptable"];
DG.DataBind();
DS.Dispose();
return true;
//}
//catch
//{
//return false;
//}
}
public bool ListData(string comstr, System.Web.UI.WebControls.GridView DG)//填充网格数据表 无起始页
{
//try
//{
if (reader != null && !reader.IsClosed)
reader.Close();
com.CommandText = comstr;
FormatComstr();
ada = new System.Data.OleDb.OleDbDataAdapter(com);
DS.Clear();
ada.Fill(DS,"temptable");
DG.DataSource = DS.Tables["temptable"];
DG.DataBind();
DS.Dispose();
return true;
// }
//catch
//{
// return false;
//}
}
public bool ListData(string comstr, System.Web.UI.WebControls.DataList DG, int page,int PageSize)//填充列表数据表 起始页为 1
{
//try
//{
if (reader != null && !reader.IsClosed)
reader.Close();
com.CommandText = comstr;
FormatComstr();
ada = new System.Data.OleDb.OleDbDataAdapter(com);
DS.Clear();
ada.Fill(DS, PageSize * (page - 1), PageSize, "temptable");
DG.DataSource = DS.Tables["temptable"];
DG.DataBind();
DS.Dispose();
return true;
//}
//catch
//{
//return false;
//}
}
public bool isChildRange(string RangeStr)
{
return false;
}
public void FormatComstr()
{
com.CommandText.Trim();
com.CommandText = com.CommandText.Replace(" "," ").ToLower();
com.CommandText = com.CommandText.Replace("where and", "where ");
com.CommandText = com.CommandText.Replace("and and", "and");
}
}
展开全部
我觉得是这里的错误,public class data : IDisposable
朋友,这些问题你应该平时多注意一下,因为这些都不是什么技术难题,本身就是写书写的问题。所以希望楼主你在以后得编程过程中要注意
代码的完整性和规范性,这样你写程序的时候你会少很多麻烦事情。因为你不必为一些非技术的问题而烦恼!
这样你的编程效率会提高很多的哈!
希望对你有帮助!
朋友,这些问题你应该平时多注意一下,因为这些都不是什么技术难题,本身就是写书写的问题。所以希望楼主你在以后得编程过程中要注意
代码的完整性和规范性,这样你写程序的时候你会少很多麻烦事情。因为你不必为一些非技术的问题而烦恼!
这样你的编程效率会提高很多的哈!
希望对你有帮助!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
简便方法是你鼠标的光标移动在那个带有波浪线的类上,点击鼠标右键,选择解析,然后在选择using 对应的命名空间,如果鼠标右键找不到解析,则说明你的项目,没有引用好对应的.dll文件,
方法是在界面右面工程上右击,选择”添加引用“,会弹出对话框,然后找到对应的.dll文件,引用进去就行了。
方法是在界面右面工程上右击,选择”添加引用“,会弹出对话框,然后找到对应的.dll文件,引用进去就行了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你上面那个data类继承的接口写错了,少了个e,应该是这样
public class data : IDisposable
public class data : IDisposable
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
IDisposabl 少个e.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询