SQL Server 数据库连接字符串的声明

WBOY
發布: 2016-06-07 16:18:23
原創
1000 人瀏覽過

连接字符串中常用的声明有: 服务器声明 Data Source、Server和Addr等。 数据库声明 Initial Catalog和DataBase等。 集成Windows账号的安全性声明 Integrated Security和Trusted_Connection等。 使用数据库账号的安全性声明 User ID和Password等。 对于访问

   连接字符串中常用的声明有:

  服务器声明 Data Source、Server和Addr等。

  数据库声明 Initial Catalog和DataBase等。

  集成Windows账号的安全性声明 Integrated Security和Trusted_Connection等。

  使用数据库账号的安全性声明 User ID和Password等。

  对于访问数据库的账号来说,,通常我们在一些参考资料上看到ADO.NET的字符串连接往往有如下写法:

  string ConnStr = "server = localhost;

  user id = sa; password = xxx; database = northwind";

  对于集成Windows安全性的账号来说,其连接字符串写法一般如下:

  string ConnStr = "server = localhost;

  integrated security = sspi; database = northwind";

  或string ConnStr = "server = localhost;

  trusted_connection = yes; database = northwind";

  使用Windows集成的安全性验证在访问数据库时具有很多优势:安全性更高、访问速度更快、减少重新设计安全架构的工作、可以硬编码连接字符串等,还是很值得使用的。

 

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!