ADO Net C# Tutorial

using System;
using System.Data;
using System.Data.SqlClient;
    class Program
    {
        static void Main(string[] args)
        {
            string sqlConnectString = "Data Source=(local);" +
                "Integrated security=SSPI;Initial Catalog=AdventureWorks;";
            SqlConnection connection = new SqlConnection(sqlConnectString);
            string selectText = "SELECT COUNT(*) FROM Person.Contact";
            SqlCommand command = new SqlCommand(selectText, connection);
            connection.Open( );
            int recordCount = (int)command.ExecuteScalar( );
            connection.Close( );
            Console.WriteLine(recordCount);
        }
    }