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

王朝mssql·作者佚名  2006-11-24
宽屏版  字体: |||超大  

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

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

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有