执行一次Sql查询,如 string  sql="select * from theTable where id= 'XXX'"
然后 SqlDataAdapter shipperAdapter = new SqlDataAdapter(sql, strConn);
假设上述代码没问题,那么当查询结果为空时(数据库中不存在),我需要根据查询结果是否为空来做为执行其他语句的条件。请问应该怎么样做(表达能力不强,请见谅)??谢谢!!

解决方案 »

  1.   

    this.m_sqlConnection = new SqlConnection(connStr);
    m_sqlCommand = new SqlCommand();
    m_sqlConnection.Open();
    m_sqlAdapter = new SqlDataAdapter();
    m_sqlAdapter.SelectCommand = this.m_sqlCommand;
    m_sqlCommand.Connection = this.m_sqlConnection;
    m_sqlCommand.CommandText = strSql;
    m_DataSet = new DataSet();
    this.m_sqlAdapter.Fill(m_DataSet);
    如上的查询出了数据库中的内容,放到了m_DataSet中的Tables[0]中,
    利用m_DataSet.Tables[0].rews.cont来判断
      

  2.   

    anthit() :你的方法是根据表中第一行的对象的总数来判断吗?
      

  3.   

    DataSet ds = new DataSet();
    shipperAdapter.Fill(ds)判断ds.Tables[0].Rows.Count是否为零