public DataTable show_num(string procedureName)
{
try
{
DataTable table = new DataTable();
con = lineserver.line();
dataadapter = new SqlDataAdapter(procedureName,con);
dataadapter.Fill(table);
lineserver.closeline();
return table;
}
catch(SqlException sqle)
{
sqle.ToString();
}
return null;
}
这是show_num方法

解决方案 »

  1.   


    protected void Page_Load(object sender, System.EventArgs e) 

                DataTable dt=new DataTable(); 
                dt = me.show_num("proc_show_products"); 
                if (dt!=null && dt.Rows.Count>0)
                {
                    for (int i = 0; i  < dt.Rows.Count; i++)//热门推荐 
                      ...
                  }

      

  2.   

    用之前判断一下你的dt里面有没有数据,是不是null
      

  3.   

    if (dt!=null && dt.Rows.Count>0)