我想检验dataset的某一行或某一个单元格是否为空
下面都不对
ds.Tables[0].Rows[i][1]!=null
ds.Tables[0].Rows[i]!=null请高人指点

解决方案 »

  1.   

    ds.Tables[0].Rows.Count>0 有记录
    ds.Tables[0].Rows.Count<1 空
      

  2.   

    if( dt.Rows.Count > 0 )
    {
       foreach( Datarow dr in dt.Rows )
       {
          for( int i=0; i<dr.Columns.Count; i++ )
         {
                if( dr[i]  == null ) //列为空
                {
                 }
                 else...
          }
        }}
    else //行为空
    {
    }
      

  3.   

    参见我的学习笔记,各种空值的比较
    http://blog.csdn.net/yumanqing/archive/2007/01/29/1497216.aspx
      

  4.   

    不行,我是执行ds.Tables[0].Rows[i].Delete();后了
    已经在记录集中把某些行删除了,但是ds.Tables[0].Rows.Count仍然保持原来的行数(因为没有update)
    只有通过查看某些行是否有内容的方法
      

  5.   

    dataset的某一行或某一个单元格是否为空 ??
    这样问有点奇怪
    dataSet是一个集合包含table
    table也是也一个集合包含rows和columns//for( int i=0; i<dr.Columns.Count; i++ ) 笔误
    改为
    for( int i=0; i<dt.Columns.Count; i++ )
      

  6.   

    ds.Tables[0].Rows[i].Delete();
    应该ds.AcceptChange(),在看看
      

  7.   

    执行delete,行还在,只是rowState 改变了
    你应该判断行的rowState
      

  8.   

    maotin(liu)很强,可见知识掌握的很扎实啊
    ds.AcceptChange()后管用判断行的rowState的是正确的方法谢谢了
      

  9.   

    ds.Tables[0].Rows[0].IsNull("Name");
                ds.Tables[0].Rows[0].IsNull(i);
      

  10.   

    单元格里字段是什么类型的??
    如果是字符串用“==”来比是不行的。
    要用ds.Tables[0].Rows[i][1].Equals(null);
        ds.Tables[0].Rows[i].Equals(null);
      

  11.   

    ds.Tables[0].Rows[i][1] != DBNull.Value;