ADO Net C# Tutorial

using System;
using System.Data;
using System.Data.SqlClient;
class MainClass
{
   static void Main(string[] args)
   {
      string connString = "server=(local)\\SQLEXPRESS;database=MyDatabase;Integrated Security=SSPI;";
      string sql = @"select firstName from Employee";
      SqlConnection conn = new SqlConnection(connString); 
      try
      {
         conn.Open();
         SqlCommand cmd = new SqlCommand(sql, conn);
         SqlDataReader rdr = cmd.ExecuteReader();
         while (rdr.Read())
         {
            Console.WriteLine("{0}", rdr[0]); 
         }
         rdr.Close();
      }
      catch(Exception e)
      {
         Console.WriteLine("Error Occurred: " + e);
      }
      finally
      {
         conn.Close();
      }
   }
}