If you are executing a query against a database, you need to know if the data has returned anything. There are many ways to test for the presence of data in an ASP.NET Web Page but only one method is the most optimal way to do it – using the Web Pages Database Helper.
First, you need to understand various Database Helper methods and what they return is required. The principal methods are:
Execute: returns int.
QueryValue returns Object.
QuerySingle returns Object
Query returns IEnumberable<Object>
For additional information visit the MSDN website.
After that, follow this tutorial:Â http://www.mikesdotnetting.com/Article/214/How-To-Check-If-A-Query-Returns-Data-In-ASP.NET-Web-Pages