日期:2014-05-17 浏览次数:20435 次
private static SqlConnection connection;
public static SqlConnection Connection
{
get
{
string conStr = ConfigurationManager.ConnectionStrings["conStr"].ConnectionString;
if (connection == null)
{
connection = new SqlConnection(conStr);
connection.Open();
}
else if (connection.State == ConnectionState.Broken)
{
int i = 1;
connection.Close();
connection.Open();
}
else if (connection.State == ConnectionState.Closed)
{
connection.Open();
}
return connection;
}
}