I am a newbie using asp.net I have a problem on what I am going to use. The problem is that i should count the number of available rooms in a hotel using SQL I use count but it’s not working is there any way to use?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I know it’s not the direct answer to your question, but it’d be much simpler if you just used
ExecuteScalarto get your count value, since you only have one row/value being returned:Since Count will always return a number with your query in SQL Server (zero if no rows), then you don’t need all the extra checks required for using the reader.