如题,网站运行一段时间久出现这种“DataBinding:“System.Data.DataRowView”不包含名为“xxx””。个人访问是没有问题的,多人访问就出现这个问题,要重新启动IIS就能正常使用.查找了一整天的资料,大部分说是试用了缓存、静态变量之类的!起重csdn里头有个哥们 (http://topic.csdn.net/t/20060617/16/4827385.html帖子这里)解决了这个问题,但没有贡献出解决方案,郁闷!我用的是三层开发,返回的ds填充的数据控件。我下面贴出一个返回一个ds的程序段出来,请大家帮忙研究下这个问题:
sqlhelper(返回ds):C# code public static DataSet Query(string SQLString) { if (SQLString != null && SQLString.Trim() != "") { using (SqlConnection connection = new SqlConnection(connectionString)) { DataSet ds = new DataSet(); try { connection.Open(); SqlDataAdapter command = new SqlDataAdapter(SQLString, connection); command.Fill(ds, "ds"); } catch (System.Data.SqlClient.SqlException ex) { throw new Exception(ex.Message); } return ds; } } else { return null; } }
定义了个interface:C# code DataSet GetList(string strWhat, string strWhere, string strOrderby);
数据层DAL:C# code public DataSet GetList(string strWhat, string strWhere, string strOrderby) { StringBuilder strSql = new StringBuilder("select " + strWhat + " from [house]"); if (string.IsNullOrEmpty(strWhat)) strWhat = "*"; if (!string.IsNullOrEmpty(strWhere)) strSql.Append(" where " + strWhere); if (!string.IsNullOrEmpty(strOrderby)) strSql.Append(" order by " + strOrderby); return SQLHelper.Query(strSql.ToString()); }
逻辑层BLL:C# code private readonly SQLHouse dal = (SQLHouse)new SQLHouse(); public DataSet GetList(string strWhat, string strWhere, string strOrderby) { DataSet ds = dal.GetList(strWhat, strWhere, strOrderby); return ds; }这里我这个项目 ds的返回 并没牵涉到缓存
前台页面:
HouseBegBLL hbbll = new HouseBegBLL();
DataSet ds7 = hbbll.GetList(" top 15 *", "pass='1' and ishave='1'", " lastdate desc");
DLyfqhz.DataSource = ds7.Tables[0].DefaultView;
DLyfqhz.DataBind();
这样绑定的数据,问题出现了!常常出现“DataBinding:“System.Data.DataRowView”不包含名为“xxx””某个字段不属于ds,而且一但出现这个问题,其他页面都跟着出错,而且不定时的,真郁闷!重启iis或者过一会又好了,真搞不懂?申明返回的该ds绝对存在页面上提示的“不包含名为“xxx””的字段,要不然有时候又是正常的,请高手们帮忙研究研究!小弟在此先谢过了
sqlhelper(返回ds):C# code public static DataSet Query(string SQLString) { if (SQLString != null && SQLString.Trim() != "") { using (SqlConnection connection = new SqlConnection(connectionString)) { DataSet ds = new DataSet(); try { connection.Open(); SqlDataAdapter command = new SqlDataAdapter(SQLString, connection); command.Fill(ds, "ds"); } catch (System.Data.SqlClient.SqlException ex) { throw new Exception(ex.Message); } return ds; } } else { return null; } }
定义了个interface:C# code DataSet GetList(string strWhat, string strWhere, string strOrderby);
数据层DAL:C# code public DataSet GetList(string strWhat, string strWhere, string strOrderby) { StringBuilder strSql = new StringBuilder("select " + strWhat + " from [house]"); if (string.IsNullOrEmpty(strWhat)) strWhat = "*"; if (!string.IsNullOrEmpty(strWhere)) strSql.Append(" where " + strWhere); if (!string.IsNullOrEmpty(strOrderby)) strSql.Append(" order by " + strOrderby); return SQLHelper.Query(strSql.ToString()); }
逻辑层BLL:C# code private readonly SQLHouse dal = (SQLHouse)new SQLHouse(); public DataSet GetList(string strWhat, string strWhere, string strOrderby) { DataSet ds = dal.GetList(strWhat, strWhere, strOrderby); return ds; }这里我这个项目 ds的返回 并没牵涉到缓存
前台页面:
HouseBegBLL hbbll = new HouseBegBLL();
DataSet ds7 = hbbll.GetList(" top 15 *", "pass='1' and ishave='1'", " lastdate desc");
DLyfqhz.DataSource = ds7.Tables[0].DefaultView;
DLyfqhz.DataBind();
这样绑定的数据,问题出现了!常常出现“DataBinding:“System.Data.DataRowView”不包含名为“xxx””某个字段不属于ds,而且一但出现这个问题,其他页面都跟着出错,而且不定时的,真郁闷!重启iis或者过一会又好了,真搞不懂?申明返回的该ds绝对存在页面上提示的“不包含名为“xxx””的字段,要不然有时候又是正常的,请高手们帮忙研究研究!小弟在此先谢过了
解决方案 »
- 要用jmail ,老是注册失败
- Jmail显示内嵌资源问题
- My97时间控件,绑定一个textbox后第一次不触发ontextchanged
- webpart
- webgrid 中返回存储过程问题,在线等,肯定结。
- 怎么样实现web页面的自定义对话框
- SOS:Object moved to here 错误(虽然此问题有三个 人问过了,但)
- 点击button后为什么不执行事件中的程序?
- 水晶报表中如何显示图像?
- 关于自定义组件的问题,如何能够使用AutoPostback
- 求助:vs2005編譯出錯 Unable to start debugging on the web server. 怎麼解決???
- 【高分求解】大家帮我看下这样的数据库设计合理否
{
throw new Exception(ex.Message);
}没有处理其他类型的异常,如果遇到其他类型的异常,极有可能返回了空对象