SqlConnection objConnection = new SqlConnection(ConfigurationSettings.AppSettings["dns"]);
objConnection.Open();
string strsql = "select * from table";
SqlCommand cmd = new SqlCommand(strsql, objConnection);
SqlDataReader rd = cmd.ExecuteReader();
if (rd.HasRows)
{
}
else
{
Response.Write("没有结果");
}我现在是通过上面得方式来判断是否有结果,然后显示出内容,我现在想简化下程序,变成
SqlConnection objConnection = new SqlConnection(ConfigurationSettings.AppSettings["dns"]);
objConnection.Open();
string strsql = "select * from table";
SqlCommand cmd = new SqlCommand(strsql, objConnection);
SqlDataReader rd = cmd.ExecuteReader();
if (如果没有结果的话)
{
Response.Write("没有结果");
}请问,这里的如果没有结果的话,这样的条件该怎么写呢?谢谢
objConnection.Open();
string strsql = "select * from table";
SqlCommand cmd = new SqlCommand(strsql, objConnection);
SqlDataReader rd = cmd.ExecuteReader();
if (rd.HasRows)
{
}
else
{
Response.Write("没有结果");
}我现在是通过上面得方式来判断是否有结果,然后显示出内容,我现在想简化下程序,变成
SqlConnection objConnection = new SqlConnection(ConfigurationSettings.AppSettings["dns"]);
objConnection.Open();
string strsql = "select * from table";
SqlCommand cmd = new SqlCommand(strsql, objConnection);
SqlDataReader rd = cmd.ExecuteReader();
if (如果没有结果的话)
{
Response.Write("没有结果");
}请问,这里的如果没有结果的话,这样的条件该怎么写呢?谢谢
cmd .ExecuteNonQuery();如果cmd .ExecuteNonQuery();为0,那么没有数据