using System;
using System.Data;
using System.Data.SqlClient;
class MainClass
{
static void Main()
{
SqlConnection conn = new SqlConnection("server=(local)\\SQLEXPRESS;database=MyDatabase;Integrated Security=SSPI;");
SqlCommand cmd = new SqlCommand();
Console.WriteLine("Command created.");
try
{
conn.Open();
}
catch (SqlException ex)
{
Console.WriteLine(ex.ToString());
}
finally
{
conn.Close();
Console.WriteLine("Connection Closed.");
}
}
}
|