Calling Stored Procedures

Stored procedures provide a degree of efficiency over the normal database calls shown so far. The program in this section uses the SQL Server data provider for working with stored procedures. Listing 19.5 shows the implementation of the SQL Server managed provider, how to create a stored procedure, and how to execute a stored procedure with parameters.

Listing 19.5. Creating and Executing a Stored Procedure: StoredProcedures.cs
 using System; using System.Data; using System.Data.SqlClient; /// <summary> /// Program demonstrating creating and /// execution of stored procedures. /// </summary> class StoredProcedures { // print shippers table to console void PrintReport() { SqlDataReader dbReader = null; SqlConnection conn ...

Get C# Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.