如题,网站运行一段时间久出现这种“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””的字段,要不然有时候又是正常的,请高手们帮忙研究研究!小弟在此先谢过了