【发布时间】:2016-11-26 17:34:12
【问题描述】:
如果基于查询返回的行数大于 0,我正在尝试打印一些内容:
using (SqlConnection con = new SqlConnection("ConnectionString")){
con.Open();
string query = "SELECT COUNT(*) FROM Some_Table WHERE Val > 5";
SqlCommand cmd = new SqlCommand(query, con);
cmd.ExecuteNonQuery(); // get the value of the count
if (count > 0)
{
Console.WriteLine("Returned more than 0 rows");
}
else
{
Console.WriteLine("Did not return more than 0 rows");
}
Console.ReadLine();
}
如何找到返回的行数?
【问题讨论】: