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;";
string sqlSelect = "SELECT COUNT(*) FROM Person.Contact";
SqlConnection connection = new SqlConnection(sqlConnectString);
SqlCommand command = new SqlCommand(sqlSelect, connection);
connection.Open( );
int count = Convert.ToInt32(command.ExecuteScalar( ));
connection.Close( );
Console.WriteLine("Record count in Person.Contact = {0}", count);
}
}
|