O'Reilly logo

Microsoft® SQL Server™ 2005: Applied Techniques Step by Step by Solid Quality Learning

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Counting Rows

Sometimes in your applications, you need to tell the user how many items are in a data table.

If you look at a sampling of e-commerce sites on the Internet, you will see that many of them on the home page inform the reader about how many items the site has available for purchase. This kind of information might be obtained by using an algorithm like this:

The same example written in Visual Basic looks like this:

Dim Counter As Integer = 0
While dataReader.Read
    Counter += 1
End While
dataReader.Close()

However, using this procedure in a table with many rows will take a very long time and require a great deal of resources. This slowdown ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required