网站访问量大的时候就出现这样的错误,少的时候不会,
代码:public IList<ProductDetail> getListBySellTypeId(int sellTypeId, int pageSize, int pageIndex, out int total)
        {
            StringBuilder sqlWhere = new StringBuilder();
            sqlWhere.Append(" sellTypeId=" + sellTypeId);
            return getThemeListByDataTable(getTable(pageSize, pageIndex, themeViewName, sqlWhere.ToString(), "productSellDate DESC", out total));
        }protected virtual DataTable getTable(int pageSize, int pageIndex, string tables, string whereSql, string orderSql, out int total)
        {
            return getTable("*", pageSize, pageIndex, tables, whereSql, orderSql, "", out total);
        }protected virtual DataTable getTable(string fields, int pageSize, int pageIndex, string tables, string whereSql, string orderSql, string group, out int total)
        {
            SqlParameter[] parameter ={
                new SqlParameter("@TableNames",tables),
                new SqlParameter("@PrimaryKey",PrimaryKey),
                new SqlParameter("@fields",fields),
                new SqlParameter("@pageSize",pageSize),
                new SqlParameter("@CurrentPage",pageIndex-1),
                new SqlParameter("@Filter",whereSql),
                new SqlParameter("@Group",group),
                new SqlParameter("@Order",orderSql),
                new SqlParameter("@Total",SqlDbType.Int),
            };
            parameter[8].Direction = ParameterDirection.Output;
            try
            {
                DataSet ds = SqlHelper.ExecuteDataset(ConnectionString, CommandType.StoredProcedure, "PagingLarge", parameter);
                //对于输出参数和返回值参数,将在 SqlDatatable.Rows[i] 关闭后 SqlCommand 完成时设置该值
                if (parameter[8].Value != null && parameter[8].Value != DBNull.Value)
                {
                    total = Convert.ToInt32(parameter[8].Value);
                }
                else
                {
                    total = 0;
                }
                return ds != null && ds.Tables.Count > 0 ? ds.Tables[0] : new DataTable();
            }
            catch (Exception ex)
            {
                string msg = string.Empty;
                msg += "方法名:getList,存储过程:PagingLarge,描述:" + ex.Message;
                for (int i = 0; i < parameter.Length; i++)
                {
                    msg += "\r\n字段名:" + parameter[i].ParameterName + ",值:" + parameter[i].Value;
                }
                log.Error(msg,ex);
                throw new DalException("数据库异常");
            }
        }private IList<ProductDetail> getThemeListByDataTable(DataTable table)
        {
            IList<ProductDetail> list = new List<ProductDetail>();
            ProductDetail product = null;
            for (int i = 0; i < table.Rows.Count; i++)
            {
                product = new ProductDetail("", "", table.Rows[i]["sellerwebName"].ToString(), "", table.Rows[i]["StoreName"].ToString());                product.ID = Convert.ToInt32(table.Rows[i]["productId"]);
                product.Name = table.Rows[i]["productName"].ToString();
                product.Money = Convert.ToDouble(table.Rows[i]["priceMoney"]);
                product.Point = Convert.ToInt32(table.Rows[i]["pricePoint"]);
                product.SmallPics = table.Rows[i]["productSmallPics"].ToString();
                product.ShowIMG = table.Rows[i]["showImg"].ToString();
                product.BigPics = table.Rows[i]["productBigPics"].ToString();
                product.isShowSmallIMG = Convert.ToBoolean(table.Rows[i]["showType"]);
                product.StoreId = Convert.ToInt32(table.Rows[i]["StoreId"]);
                product.SellerId = table.Rows[i]["SellerId"].ToString();
                product.ShowPosition = Convert.ToInt32(table.Rows[i]["showPosition"]);
                product.ShowPositionType = Convert.ToInt32(table.Rows[i]["showPositionType"]);
                list.Add(product);
            }
            return list;
        }

解决方案 »

  1.   

    不要用parameter[8].Direction 这种代码,要么用实体,要么写好名称,用数字什么的难维护
      

  2.   

    不属于表说明字段sellerwebName在表里面没有该列,如果你想用这名字就as一下把
      

  3.   

    parameter[8].Direction 这样写与那个错误好像没有关系吧,不过还是很感激你们
    这个问题现在很急啊,上面一直催,急死了,而且重启iis又不会了,等一下访问量大就会了
      

  4.   

    你判断table的DataColumns是否包含该字段就行了
      

  5.   

    if(Tableda.Columns.Contains("sellerwebName")==true)
    {
      //有这一列
    }
    else
    {
    //没有
    }
      

  6.   


    很多这中问题,应该和数据库有关.打开下数据库跟踪,看看到底都执行了什么操作
    还有就是数据库并发操作问题
    http://topic.csdn.net/u/20090302/11/a879af02-647b-43c6-b425-71ec4eb98b9c.html