且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

连接字符串中的Trusted_Connection和Integrated Security有什么区别?

更新时间:2023-11-06 11:44:52

它们彼此是同义词,可以互换使用。

They are synonyms for each other and can be used interchangeably.

.Net中有一个名为 SqlConnectionStringBuilder ,对于使用类型安全属性来构建字符串的某些部分的 SQL Server 连接字符串非常有用。此类保留一个内部同义词列表,以便可以从一个值映射到另一个值:

In .Net, there is a class called SqlConnectionStringBuilder that is very useful for dealing with SQL Server connection strings using type-safe properties to build up parts of the string. This class keeps an internal list of synonyms so it can map from one value to another:


+----------------------+-------------------------+
| Value                | Synonym                 |
+----------------------+-------------------------+
| app                  | application name        |
| async                | asynchronous processing |
| extended properties  | attachdbfilename        |
| initial file name    | attachdbfilename        |
| connection timeout   | connect timeout         |
| timeout              | connect timeout         |
| language             | current language        |
| addr                 | data source             |
| address              | data source             |
| network address      | data source             |
| server               | data source             |
| database             | initial catalog         |
| trusted_connection   | integrated security     |
| connection lifetime  | load balance timeout    |
| net                  | network library         |
| network              | network library         |
| pwd                  | password                |
| persistsecurityinfo  | persist security info   |
| uid                  | user id                 |
| user                 | user id                 |
| wsid                 | workstation id          |
+----------------------+-------------------------+

(在Reflector的帮助下进行编译)

还有其他类似的类可用于处理 ODBC OleDb 连接字符串,但不幸的是,其他数据库供应商一无所获-我假设供应商的图书馆有责任提供这种实现。

There are other similar classes for dealing with ODBC and OleDb connection strings, but unfortunately nothing for other database vendors - I would assume the onus is on a vendor's library to provide such an implementation.