问题是这样的,我通过 select sum(sale) from sales where date>='2010/01/01' and date<='2010/06/01' 查询数据填充到用 DataSet 定义的ds1 中。
然后用if语句判断ds1中有没有数据来决定是否填充Chart控件。
我是用
if(ds1.Tables[0].Rows.Count>0)
{}
else
{
     respons.write("");
}
来进行判断的,问题就出现了:因为select sum(sale) from sales where date>='2010/01/01' and date<='2010/06/01' 执行后即使没有数据也会显示一行"NULL"的值所以程序就在这里出错了请问各位朋友,有没有什么好方法来解决这个问题?多谢了!

解决方案 »

  1.   

    你就费个事   如果为count==1   就判断是否是null
      

  2.   

    if(ds1.Tables[0].Rows!=null&&ds1.Tables[0].Rows.Count>0)
    {}
    else
    {
      respons.write("");
    }
    试试这个。
      

  3.   

     select sum(sale) from sales where date>='2010/01/01' and date<='2010/06/01' 
    定义个sqldatareader来读取。
    然后判断 的人dr.IsDbNull(0) //只有1列数据所以是 0
    这样就可以了
      

  4.   

    select CASE sum(sale) WHEN NULL THEN 0 ELSE sum(sale) END AS Total_sale from sales where date>='2010/01/01' and date<='2010/06/01'
      

  5.   

    首先要判断ds是否为null
    然后看有没有table[0]
    然后再看rows
      

  6.   

    if(ds1!=null && ds1.Tables.Count>0 && ds1.Tables[0].Rows.Count>0)
    {
      string str = ds1.Tables[0].Rows[0][0].ToString();
     int count= 0;
    if(str!=""){
     try{count= int.Parse(str);}catch(Exception e){}
    }
    }
    else
    {
      respons.write("");
    }
      

  7.   

    select isnull(sum(sale),0) from sales where date>='2010/01/01' and date<='2010/06/01' 
    if(ds1!=null && ds1.Tables[0].Rows.Count>0)
    {}