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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.