连接数据库代码不解
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;
}
}