连接数据源

Connection对象。Connection对象处于最顶层,是所有数据访问请求的关口。我们通过其暴露的属性进行配置。下面是一段连接字符串的示例。

 

 1 if (string.IsNullOrEmpty(con.ConnectionString))
 2             {
 3                 con.ConnectionString = "Data Source=localhost\\sql08; Initial Catalog=ado_test;user ID=sa;password=test;";// Integrated Security=SSPI
 4             }
 5 
 6             if (con.State != ConnectionState.Open)
 7             {
 8                 con.Open();
 9             }
10             if (con.State == ConnectionState.Open)
11                 lbConnect.Text = "CONNECTED NOW!";
View Code

相关文章:

  • 2021-09-29
  • 2022-12-23
  • 2022-01-22
  • 2022-02-21
  • 2022-01-05
  • 2021-11-12
  • 2021-07-26
猜你喜欢
  • 2022-12-23
  • 2021-12-06
  • 2022-12-23
  • 2021-07-07
  • 2022-01-30
  • 2021-11-18
  • 2021-08-27
相关资源
相似解决方案