c# - 如何测试 DataSet 是否为空?

标签 c# ado.net dataset

我正在修改其他人的代码,其中使用以下代码执行查询:

DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(sqlString, sqlConn);
da.Fill(ds);

如何判断数据集是否为空(即没有返回结果)?

最佳答案

如果我没理解错的话,这应该对你有用

if (ds.Tables[0].Rows.Count == 0)
{
    //
}

关于c# - 如何测试 DataSet 是否为空?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2976473/

相关文章:

r - 在 R 控制台上查看大数据集

sql-server - 是否可以列出 SSRS 中结果集中实际使用的字段?

c# - 如何映射到 NHibernate 中的 SortedList

c# - IIS 部署在 cassini 中运行正常后,PrincipalContext.ValidateCredentials 停止验证

entity-framework - 如何使用 Entity Framework 4.1 将连接字符串传递给数据库优先 DBContext 的构造函数?

c# - 这个 LINQ 查询什么时候进入数据库?

sql - Spark数据集错误: Both sides of this join are outside the broadcasting threshold and computing it could be prohibitively expensive

HKCU 的 c# 权限

c# - WPF 椭圆剪裁

entity-framework - 如何在实体设计器中映射每个类型的表(TPT)继承?