Reputation: 5459
Hi I am tryng to count the number of rows in a table but I alwyas get back -1.Here is my code:
using (connection = new SqlConnection(connectionString))
{
connection.Open();
SqlCommand command = new SqlCommand("CountBooks", connection);
command.CommandType = CommandType.StoredProcedure;
numberOfBooks = command.ExecuteNonQuery();
}
And here is my query:
SELECT COUNT(*) FROM Books
How can I get the correct result?
Upvotes: 1
Views: 66