I have a stored procedure which returns a certain number of rows.
Case 1: When I use SqlDataAdapter
SqlDataAdapter sdAdapter = new SqlDataAdapter();
ds = new DataSet();
sdAdapter.SelectCommand = myCommand;
sdAdapter.Fill(ds);
int recordCount = ds.Tables[0].Rows.Count;
Case 2: When I use SqlDataReader
SqlDataReader reader = myCommand.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
recordCount++;
}
}
In Case 1, the recordCount is 15 which is correct.
In Case 2, for some reason, reader.HasRows is returning false.
Am I doing anything wrong in terms of syntax? I am confident that myCommand has been built properly since I do get the count in Case 1.
Any help would be really appreciated.
Thank you