Code
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
string connString = @"Data Source=s013;database=northwind;integrated security=true";
SqlConnection conn = new SqlConnection(connString);
try
{
conn.Open();
Console.WriteLine("Connection opened!");
Console.WriteLine("Connection properties:");
Console.WriteLine("\tConnection String:{0}", conn.ConnectionString);
Console.WriteLine("\tDataBase:{0}", conn.Database);
Console.WriteLine("\tDataSource{0}:",conn.DataSource);
Console.WriteLine("\tServerVersion{0}",conn.ServerVersion);
Console.WriteLine("\tState:",conn.State.ToString());
Console.WriteLine("\tWorkStationId:",conn.WorkstationId.ToString());
}
catch (SqlException ex)
{
Console.WriteLine("Error:" + ex.Message);
}
finally
{
conn.Close();
Console.WriteLine("Connection Closed!");
}
Console.ReadLine();
}
}
}
posted @
2008-11-21 11:23
Thinking.N
阅读(
145)
评论()
编辑
收藏
举报