using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;

namespace SimpleExample {
	class Program {
		static void Main (string[] args){
			try {
				SqlConnection connection = new SqlConnection (
					"server=localhost; database=AdventureWorks; uid=sa; pwd=dbadmin"
					);

				SqlCommand command = connection.CreateCommand ();
				command.CommandText =
					"SELECT Title, FirstName, LastName, EmailAddress " +
					"FROM Person.Contact " +
					"WHERE ContactID = 8";

				connection.Open ();
				SqlDataReader dataReader = command.ExecuteReader ();
				dataReader.Read ();

				Console.WriteLine (dataReader["Title"] + " " + dataReader["FirstName"] + " " +
					dataReader["LastName"] + ", " + dataReader["EmailAddress"]);

				dataReader.Close ();
				connection.Close ();
			} catch (SqlException e) {
				Console.WriteLine ("Exception: " + e.Message);
			}

			Console.ReadLine ();
		}
	}
}
