using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;


public partial class StoredProcedures
{
  [Microsoft.SqlServer.Server.SqlProcedure]
  public static void Accessors()
  {
    SqlConnection conn = new SqlConnection("context connection=true");
    conn.Open();
    SqlCommand cmd = conn.CreateCommand();
    cmd.CommandText = "select * from authors";
    cmd.CommandType = CommandType.Text;

    SqlDataReader rdr = cmd.ExecuteReader();
    while (rdr.Read() == true)
    {
      String s;
      // 1. Use ordinals or names
      //    implicit casting, if you know the right type
      s = (string)rdr[0];
      s = (string)rdr["au_id"];

      // 2. Use GetValue (must cast)
      s = (string)rdr.GetValue(0);

      // 3. Strong typed accessors
      s = rdr.GetString(0);

      // 4. Accessors for SqlTypes
      SqlString s2 = rdr.GetSqlString(0);
    }
  }
}
