首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

DataView 判断替空的方法

2012-08-29 
DataView 判断为空的方法执行如下操作:SqlDataAdapter adapter new SqlDataAdapter(sql, clsMain.Gcon)

DataView 判断为空的方法
 
  执行如下操作:

  SqlDataAdapter adapter = new SqlDataAdapter(sql, clsMain.Gcon);
  DataSet ds = new DataSet();
  adapter.Fill(ds);
  DataView dv = ds.Tables[0].DefaultView;

如何判断 dv 中没有数据 即查询的结果为空呢??

[解决办法]
if (搜索数据 != null && 搜索数据.Tables.Count > 0)
[解决办法]
ds != Null&&ds.tables.count>0
[解决办法]
ds.tables[0].rows[0].count>0
[解决办法]
if(ds!=null && ds.tables.count!=0 && ds.tables[0].rows.count!=0)我都是这么判断的

热点排行