O'Reilly logo

Sams Teach Yourself ADO.NET in 24 Hours by Paul Bertucci, Jason Lefebvre

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

Executing a Stored Procedure

There are a few different ways to execute stored procedures within ADO.NET. The first section following uses methods you've already seen. Then, you'll see the generally accepted standard way of executing the stored procedure.

Using Exec()

In Hour 6, “Retrieving Data from the Data Source,” you saw how to create Connection, Command, and DataReader objects and use them to retrieve data from your database. As you recall, the ExecuteReader() method of the DataReader object returns a forward-only, read-only resultset, which you can then use to bind to a list control, or step through manually.

Almost precisely the same code can be reused to call a stored procedure. Rather than placing a query into the Command object, you ...

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