Tuesday, December 13, 2011

SqlDataReader to Retrieve Multiple Rows


SqlDataReader to Retrieve Multiple Rows

The SqlDataReader approach to retrieve multiple rows is illustrated in the following code fragment.

using System.IO;

using System.Data;

using System.Data.SqlClient;



public SqlDataReader RetrieveRowsWithDataReader()

{

  SqlConnection conn = new SqlConnection(

         "server=(local);Integrated Security=SSPI;database=northwind");

  SqlCommand cmd = new SqlCommand("DATRetrieveProducts", conn );

  cmd.CommandType = CommandType.StoredProcedure;

  try