SQL Server 数据库连接字符串的声明
连接字符串中常用的声明有: 服务器声明 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集成的安全性验证在访问数据库时具有很多优势:安全性更高、访问速度更快、减少重新设计安全架构的工作、可以硬编码连接字符串等,还是很值得使用的。
推荐阅读
-
C#实现连接SQL Server2012数据库并执行SQL语句的方法
-
SQL Server中通过reverse取某个最后一次出现的符号后面的内容(字符串反转)
-
浅谈SQL Server中的三种物理连接操作(性能比较)
-
C#与SQL连接:GridView控件对数据库的操作
-
C#如何实现对sql server数据库的增删改查
-
SQL Server数据库开发的二十一条法则
-
还原sql server数据库的处理方法
-
sql server 还原数据库时提示数据库正在使用,无法进行操作的解决方法
-
远程连接局域网内的sql server 无法连接 错误与解决方法
-
SQL Server 数据库的备份详细介绍及注意事项