执行如下操作:            SqlDataAdapter adapter = new SqlDataAdapter(sql, clsMain.Gcon);
             DataSet ds = new DataSet();
             adapter.Fill(ds);
             DataView dv = ds.Tables[0].DefaultView;如何判断 dv 中没有数据 即查询的结果为空呢??

解决方案 »

  1.   

    if (搜索数据 != null && 搜索数据.Tables.Count > 0)
      

  2.   

    必须两个条件都满足啊 如同我的代码:ds.tables.count>0 && ds != Null
    是这样嘛?
      

  3.   

    ds != Null&&ds.tables.count>0 
      

  4.   

    if(ds!=null && ds.tables.count!=0 && ds.tables[0].rows.count!=0)我都是这么判断的
      

  5.   

    vb.net:
    if dv isnot nothing then
     if dv.count>0 then
       ...
     else
       messagebox.show("数据为空")
     end if
     messagebox.show("查询失败")
    end if
      

  6.   

    写错了,正确的是:
    if dv isnot nothing then
     if dv.count>0 then
      ...
     else
      messagebox.show("数据为空")
     end if
    else
     messagebox.show("查询失败")
    end if
      

  7.   

    写程序重点在调试,如果[搜索数据]不是表怎么可能会有[.Tables.Count]?看语句不一定就能非常明白,调试决定一切。