Ajax.NET and paging example

Read Michael Schwarz's blog entry SQL Server 2005 and Ajax.NET Professional - RowNumber Example . He showed how to create simple paging method that returns data to client script wich should render this data.

[AjaxPro.AjaxMethod]
public static DataTable GetAllContacts(int pageIndex, int pageSize)
{
     SqlConnection conn = new SqlConnection([...]);

     try
     {
          conn.Open();

          try
         
{
               DataTable dt = new DataTable();

               SqlCommand cmd = new SqlCommand("GetAddressList", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@PageIndex", SqlDbType.Int).Value = pageIndex;
               cmd.Parameters.Add("@PageSize", SqlDbType.Int).Value = pageSize;

               SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(dt);

                return dt;
          }
          catch (Exception ex)
          {
               throw ex;
          }
          finally
          {
               conn.Close();
               conn.Dispose();
          }
     }
     catch (Exception ex)
     {
          throw ex;
     }

     return null;
}