找回密码
 注册
搜索
热搜: 回贴
微赢网络技术论坛 门户 数据库 MSSQL 查看内容

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

2009-12-26 01:23| 发布者: admin| 查看: 105| 评论: 0|原作者: 小可爱

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

最新评论

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-29 15:35 , Processed in 0.228831 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

返回顶部