一般的远程访问的写成这样:

Data Source=IP ;Initial Catalog=数据库名 ;UserID= 用户名 ;Password=密码

本地访问的写成这样:

Data Source=(local);Initial Catalog=数据库名 ;UserID= 用户名 ;Password=密码

如果是本地的,通过windows组件验证的(也就是没有用户名,密码的)写成这样:

Data Source=(local);Initial Catalog=数据库名 ;Integrated Security=True

如果不是默认的实例,假如实例名是SQLEXPRESS,写成这样:

Data Source=(local)/SQLEXPRESS ;Initial Catalog=数据库名 ;Integrated Security=True

 

 

ExecuteReader 
简单高效的,单向前的数据查询。返回一个SqlDataReader对象 
通常用于读取数据 

ExecuteNonQuery 
返回一个int类型的值,返回数据库中所影响的行数。 
用于对数据库的各种操作

ExecuteScalar 
返回读出结果的第一行第一列

 

 

 

相关文章:

  • 2021-12-05
  • 2021-11-22
  • 2021-06-07
  • 2021-11-04
  • 2021-09-21
  • 2022-02-07
  • 2021-11-21
  • 2021-11-24
猜你喜欢
  • 2021-08-09
  • 2022-12-23
  • 2021-09-13
  • 2022-01-15
  • 2021-11-06
  • 2021-08-06
  • 2021-11-23
相关资源
相似解决方案