我的ado是这样写的 public DataSet getlist(string ab)
{
using (SqlConnection cn = new SqlConnection (sqlstr ))
{
string juzi = "select * from DepartmentInfo";
DataSet ds = new DataSet ();
if (ab != "")
{
juzi = "select * from DepartmentInfo where "+ab ;
}
try
{
cn.Open();
SqlDataAdapter ada = new SqlDataAdapter(juzi,sqlstr );
ada.Fill(ds);
}
catch (System.Data.SqlClient.SqlException ex)
{
throw (ex);
} return ds;
}
}然后我在前面调用的时候 条件输了一个错误的 查询语句变成 select * from DepartmentInfo where sID=1 (假设没有sID=1这条记录) 但是他返回的为什么不是空的dataset?以至于我在前台判断他的时候 ds == null 没用 要用这句才行 ds.Tables[0].Rows.Count == 0 这是为什么呢?
{
using (SqlConnection cn = new SqlConnection (sqlstr ))
{
string juzi = "select * from DepartmentInfo";
DataSet ds = new DataSet ();
if (ab != "")
{
juzi = "select * from DepartmentInfo where "+ab ;
}
try
{
cn.Open();
SqlDataAdapter ada = new SqlDataAdapter(juzi,sqlstr );
ada.Fill(ds);
}
catch (System.Data.SqlClient.SqlException ex)
{
throw (ex);
} return ds;
}
}然后我在前面调用的时候 条件输了一个错误的 查询语句变成 select * from DepartmentInfo where sID=1 (假设没有sID=1这条记录) 但是他返回的为什么不是空的dataset?以至于我在前台判断他的时候 ds == null 没用 要用这句才行 ds.Tables[0].Rows.Count == 0 这是为什么呢?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货