在Visual C#.NET中如何使用ADO控件连接SQL Server 2000数据,详细点啊
展开全部
private static SqlConnection connection;
public static SqlConnection Connection
{
get
{
// string connectionString = "Data Source=.;Initial Catalog=Tjj_DataBaseSQL;Integrated Security=True";
string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
if (connection == null)
{
connection = new SqlConnection(connectionString);
connection.Open();
}
else if (connection.State == System.Data.ConnectionState.Closed)
{
connection.Open();
}
else if (connection.State == System.Data.ConnectionState.Broken)
{
connection.Close();
connection.Open();
}
return connection;
}
}
public static SqlConnection Connection
{
get
{
// string connectionString = "Data Source=.;Initial Catalog=Tjj_DataBaseSQL;Integrated Security=True";
string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
if (connection == null)
{
connection = new SqlConnection(connectionString);
connection.Open();
}
else if (connection.State == System.Data.ConnectionState.Closed)
{
connection.Open();
}
else if (connection.State == System.Data.ConnectionState.Broken)
{
connection.Close();
connection.Open();
}
return connection;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询