@Osama Abdelkader , If you want to get the count of the rows in the table, there is no need to use the SqlDatareader.
Here is a code example you could refer to.
Code:
string connstr = "connstr";
SqlConnection connection = new SqlConnection(connstr);
connection.Open();
string comamnd = "select COUNT(*) from Student";
SqlCommand com = new SqlCommand(comamnd, connection);
int Cond = Convert.ToInt32(com.ExecuteScalar().ToString());
Console.WriteLine(Cond);
connection.Close();
Hope the code example could help you. If I have some misunderstanding, Pleas feel free to let me know.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.