Get all the rows from query result
I have a stored procedure that returns a boolean. (0 or 1). It returns
multiple rows. my question is how to iterate through all the result.
using (SqlConnection con = new
SqlConnection(ConfigurationManager.ConnectionStrings["DBReader"].ConnectionString))
{
using (SqlCommand com = new
SqlCommand("Reader.usp_CheckerIsStopped", con))
{
com.CommandType = CommandType.StoredProcedure;
com.Parameters.Add("@fld_UserID", SqlDbType.Int).Value =
this.UserID;
con.Open();
SqlDataReader dr = com.ExecuteReader();
if (dr.Read() == 1)
{
return true;
}
else
{
return false;
}
}
}
It has a error in "dr.Read() == 1".
Error: "Operator == cannot be applied to type bool to int"
No comments:
Post a Comment