if (ds.Tables[0].Rows[0]["BirthDate"] != DBNull.Value) 
--------------------
  if (ds.Tables[0].Rows[0]["BirthDate"] != DBNull) 
试试

解决方案 »

  1.   

     if (ds.Tables[0].Rows[0]["BirthDate"] != DBNull.Value) 
    修改为:
    if (!ds.Tables[0].Rows[0].IsNull("BirthDate")) 
      

  2.   

    ds.Tables[0].Rows[0]["BirthDate"]是已经去读取BirthDate字段的值了,如果为null,就报错了,压根就不会和后面的DBNull.Value去比较了
      

  3.   

    你这不是类库引用的问题,BirthDate 类型是什么? 
    两边类型不一致,不能比较