利用 OLE DB Driver for SQL Server 使用連接字串關鍵字Using Connection String Keywords with OLE DB Driver for SQL Server

適用於: 是SQL Server 是Azure SQL Database 是Azure Synapse Analytics (SQL DW) 是平行處理資料倉儲 APPLIES TO: yesSQL Server yesAzure SQL Database yesAzure Synapse Analytics (SQL DW) yesParallel Data Warehouse

下載OLE DB 驅動程式下載DownloadDownload OLE DB Driver

SQL Server Api 的某些 OLE DB 驅動程式會使用連接字串來指定連接屬性。Some OLE DB Driver for SQL Server APIs use connection strings to specify connection attributes. 連接字串是關鍵字和關聯值的清單,每一個關鍵字都會識別特定的連接屬性。Connection strings are lists of keyword and associated values; each keyword identifies a particular connection attribute.

注意

OLE DB Driver for SQL Server 允許模稜兩可的連接字串,以維護回溯相容性 (例如,某些關鍵字可能會指定一次以上,而且可能會允許衝突的關鍵字,好讓解決方案以位置或優先順序為根據)。OLE DB Driver for SQL Server allows ambiguity in connection strings to maintain backward compatibility (for example, some keywords may be specified more than once, and conflicting keywords may be allowed with resolution based on position or precedence). SQL Server 的 OLE DB 驅動程式的未來版本,在連接字串中可能不會造成混淆。Future releases of OLE DB Driver for SQL Server might not allow ambiguity in connection strings. 修改應用程式時,適合使用適用於 SQL Server 的 OLE DB 驅動程式來消除任何對於模稜兩可連接字串的相依性。It is good practice when modifying applications to use OLE DB Driver for SQL Server to eliminate any dependency on connection string ambiguity.

下列各節描述在使用 SQL Server 做為資料提供者的 OLE DB 驅動程式時,可以與 OLE DB Driver for SQL Server 和 ActiveX Data Objects (ADO)搭配使用的關鍵字。The following sections describe the keywords that can be used with the OLE DB Driver for SQL Server, and ActiveX Data Objects (ADO) when using OLE DB Driver for SQL Server as the data provider.

OLE DB 驅動程式連接字串關鍵字OLE DB Driver Connection String Keywords

OLE DB 應用程式有兩種方法可初始化資料來源物件:There are two ways OLE DB applications can initialize data source objects:

  • IDBInitialize::InitializeIDBInitialize::Initialize

  • IDataInitialize::GetDataSourceIDataInitialize::GetDataSource

在第一個案例中,提供者字串可用來初始化連接屬性,其方式是在 DBPROPSET_DBINIT 屬性集中設定 DBPROP_INIT_PROVIDERSTRING 屬性。In the first case, a provider string can be used to initialize connection properties by setting the property DBPROP_INIT_PROVIDERSTRING in the DBPROPSET_DBINIT property set. 在第二個案例中,初始化字串可以傳遞給 IDataInitialize::GetDataSource 方法來初始化連接屬性。In the second case, an initialization string can be passed to IDataInitialize::GetDataSource method to initialize connection properties. 這兩個方法都會初始化相同的 OLE DB 連接屬性,但是會使用不同的關鍵字集合。Both methods initialize the same OLE DB connection properties, but different sets of keywords are used. IDataInitialize::GetDataSource 所使用的關鍵字集合,至少是初始化屬性群組內的屬性描述。The set of keywords used by IDataInitialize::GetDataSource is at minimum the description of properties within the initialization property group.

如果任何提供者字串設定所包含的對應 OLE DB 屬性設定為預設值或明確設定為某個值,OLE DB 屬性值將在提供者字串中覆寫此設定。Any provider string setting that has a corresponding OLE DB property set to some default value or explicitly set to a value, the OLE DB property value will override the setting in the provider string.

在提供者字串中透過 DBPROP_INIT_PROVIDERSTRING 值所設定的布林屬性是使用 "yes" 和 "no" 的值所設定。Boolean properties set in provider strings via DBPROP_INIT_PROVIDERSTRING values are set using the values "yes" and "no". 在初始化字串中使用 IDataInitialize::GetDataSource 所設定的布林值屬性,是使用 "True" 和 "False" 的值所設定。Boolean properties set in initialization strings using IDataInitialize::GetDataSource are set using the values "true" and "false".

使用 IDataInitialize::GetDataSource 的應用程式,也可以使用 IDBInitialize::Initialize 所用的關鍵字,但是只適用於沒有預設值的屬性。Applications using IDataInitialize::GetDataSource can also use the keywords used by IDBInitialize::Initialize but only for properties that do not have a default value. 如果應用程式在初始化字串中同時使用 IDataInitialize::GetDataSource 關鍵字和 IDBInitialize::Initialize 關鍵字,則會使用 IDataInitialize::GetDataSource 關鍵字設定。If an application uses both the IDataInitialize::GetDataSource keyword and the IDBInitialize::Initialize keyword in the initialization string, the IDataInitialize::GetDataSource keyword setting is used. 強烈建議您不要讓應用程式在 IDataInitialize:GetDataSource 連接字串中使用 IDBInitialize::Initialize 關鍵字,因為將來的版本可能無法維護這個行為。It is strongly recommended that applications do not use IDBInitialize::Initialize keywords in IDataInitialize:GetDataSource connection strings, as this behavior may not be maintained in future releases.

注意

透過 IDataInitialize::GetDataSource 傳遞的連接字串會經由 IDBProperties::SetProperties 轉換成屬性並加以套用。A connection string passed through IDataInitialize::GetDataSource is converted into properties and applied via IDBProperties::SetProperties. 如果元件服務在 IDBProperties::GetPropertyInfo 中找到屬性描述,此屬性將會作為獨立屬性來套用。If component services found the property description in IDBProperties::GetPropertyInfo, this property will be applied as a stand-alone property. 否則,它將會透過 DBPROP_PROVIDERSTRING 屬性來套用。Otherwise, it will be applied through DBPROP_PROVIDERSTRING property. 例如,如果您指定連接字串資料來源 = server1;Server = server2資料來源將會設定為屬性,但是伺服器會進入提供者字串。For example, if you specify connection string Data Source=server1;Server=server2, Data Source will be set as a property, but Server will go into a provider string.

如果您指定相同提供者特有之屬性的多個執行個體,將會使用第一個屬性的值。If you specify multiple instances of the same provider-specific property, the first value of the first property will be used.

OLE DB 應用程式使用的連接字串如果搭配 IDBInitialize::Initialize 使用 DBPROP_INIT_PROVIDERSTRING,其語法如下:Connection strings used by OLE DB applications using DBPROP_INIT_PROVIDERSTRING with IDBInitialize::Initialize have the following syntax:

connection-string ::= empty-string[;] | attribute[;] | attribute; connection-string

empty-string ::=

attribute ::= attribute-keyword=[{]attribute-value[}]

attribute-value ::= character-string

attribute-keyword ::= identifier

可以選擇用大括號括住屬性值,這樣是很好的作法。Attribute values can optionally be enclosed in braces, and it is good practice to do so. 如此可在屬性值包含非英數字元時避免問題發生。This avoids problems when attribute values contain non-alphanumeric characters. 值中的第一個右大括號應該會結束該值,所以值不能包含右大括號字元。The first closing brace in the value is assumed to terminate the value, so values cannot contain closing brace characters.

連接字串關鍵字 = 符號後面的空格字元應該解譯為常值,即使該值括在引號內也是如此。A space character after the = sign of a connection string keyword will be interpreted as a literal, even if the value is enclosed in quotation marks.

下表描述可搭配 DBPROP_INIT_PROVIDERSTRING 使用的關鍵字。The following table describes the keywords that may be used with DBPROP_INIT_PROVIDERSTRING.

關鍵字Keyword 初始化屬性Initialization property DescriptionDescription
AddrAddr SSPROP_INIT_NETWORKADDRESSSSPROP_INIT_NETWORKADDRESS "Address" 的同義字。Synonym for "Address".
位址Address SSPROP_INIT_NETWORKADDRESSSSPROP_INIT_NETWORKADDRESS 執行 SQL ServerSQL Server 執行個體之伺服器的網路位址。The network address of the server running an instance of SQL ServerSQL Server. Address 通常是伺服器的網路名稱,不過也可能是其他名稱,例如管道、IP 位址,或 TCP/IP 通訊埠和通訊端位址。Address is usually the network name of the server, but can be other names such as a pipe, an IP address, or a TCP/IP port and socket address.

若您指定 IP 位址,請確定在 SQL ServerSQL Server 組態管理員中已啟用 TCP/IP 或具名管道通訊協定。If you specify an IP address, make sure that the TCP/IP or named pipes protocols are enabled in SQL ServerSQL Server Configuration Manager.

使用 SQL Server 的 OLE DB 驅動程式時,位址的值會優先于連接字串中傳遞給伺服器的值。The value of Address takes precedence over the value passed to Server in connection strings when using OLE DB Driver for SQL Server. 同時請注意,Address=; 將會連接到 Server 關鍵字中指定的伺服器,而 Address= ;, Address=.;Address=localhost;Address=(local); 都會造成與本機伺服器的連接。Also note that Address=; will connect to the server specified in the Server keyword, whereas Address= ;, Address=.;, Address=localhost;, and Address=(local); all cause a connection to the local server.

Address 關鍵字的完整語法如下:The complete syntax for the Address keyword is as follows:

[通訊協定 : ]位址[ , 連接埠 |\pipe\pipename][protocol:]Address[,port |\pipe\pipename]

protocol 可以是 tcp (TCP/IP)、 lpc (共用記憶體) 或 np (具名管道)。protocol can be tcp (TCP/IP), lpc (shared memory), or np (named pipes). 如需通訊協定的詳細資訊,請參閱設定用戶端通訊協定For more information about protocols, see Configure Client Protocols.

如果未指定_通訊協定_或網路關鍵字,SQL Server 的 OLE DB 驅動程式會使用 SQL ServerSQL Server Configuration Manager 中所指定的通訊協定順序。If neither protocol nor the Network keyword is specified, OLE DB Driver for SQL Server will use the protocol order specified in SQL ServerSQL Server Configuration Manager.

port 是在指定伺服器上所要連接的通訊埠。port is the port to connect to, on the specified server. 根據預設,SQL ServerSQL Server 會使用通訊埠 1433。By default, SQL ServerSQL Server uses port 1433.
APPAPP SSPROP_INIT_APPNAMESSPROP_INIT_APPNAME 識別應用程式的字串。The string identifying the application.
ApplicationIntentApplicationIntent SSPROP_INIT_APPLICATIONINTENTSSPROP_INIT_APPLICATIONINTENT 宣告連接到伺服器時的應用程式工作負載類型。Declares the application workload type when connecting to a server. 可能的值為 ReadOnlyReadWritePossible values are ReadOnly and ReadWrite.

預設值為ReadWriteThe default is ReadWrite. 如需 SQL Server 支援 AlwaysOn 可用性群組Always On availability groups OLE DB 驅動程式的詳細資訊,請參閱OLE DB 驅動程式,以取得高可用性、嚴重損壞修復的 SQL Server 支援For more information about OLE DB Driver for SQL Server's support for AlwaysOn 可用性群組Always On availability groups, see OLE DB Driver for SQL Server Support for High Availability, Disaster Recovery.
AttachDBFileNameAttachDBFileName SSPROP_INIT_FILENAMESSPROP_INIT_FILENAME 可附加資料庫的主要檔案名稱,包括完整路徑名稱。The name of the primary file (include the full path name) of an attachable database. 若要使用 AttachDBFileName,您還必須使用提供者字串 Database 關鍵字來指定資料庫名稱。To use AttachDBFileName, you must also specify the database name with the provider string Database keyword. 如果之前已附加資料庫,SQL ServerSQL Server 不會重新附加它 (它會使用附加的資料庫當做連接的預設值)。If the database was previously attached, SQL ServerSQL Server does not reattach it (it uses the attached database as the default for the connection).
驗證1Authentication1 SSPROP_AUTH_MODESSPROP_AUTH_MODE 指定使用的 SQL 或 Active Directory 驗證。Specifies the SQL or Active Directory authentication used. 有效值為:Valid values are:
  • (not set):由其他關鍵字決定的驗證模式。(not set): Authentication mode determined by other keywords.
  • 使用 Azure Active Directory 身分識別 ActiveDirectoryPassword:User 識別碼和密碼驗證。ActiveDirectoryPassword:User ID and password authentication with an Azure Active Directory identity.
  • 使用 Azure Active Directory 身分識別 ActiveDirectoryIntegrated: 整合式驗證。ActiveDirectoryIntegrated: Integrated authentication with an Azure Active Directory identity.

  • 注意: ActiveDirectoryIntegrated 關鍵字也可以用於 Windows 驗證以 SQL Server。NOTE: The ActiveDirectoryIntegrated keyword can also be used for Windows authentication to SQL Server. 它會取代 Integrated Security (或 Trusted_Connection)驗證關鍵字。It replaces Integrated Security (or Trusted_Connection) authentication keywords. 建議使用 Integrated Security (或 Trusted_Connection)關鍵字或其對應屬性的應用程式將 Authentication 關鍵字的值(或其對應的屬性)設定為 ActiveDirectoryIntegrated,以啟用新的加密和憑證驗證行為.It's recommended that applications using Integrated Security (or Trusted_Connection) keywords or their corresponding properties set the value of the Authentication keyword (or its corresponding property) to ActiveDirectoryIntegrated to enable new encryption and certificate validation behavior.

  • ActiveDirectoryInteractive: 具有 Azure Active Directory 身分識別的互動式驗證。ActiveDirectoryInteractive: Interactive authentication with an Azure Active Directory identity. 這個方法支援 Azure 多重要素驗證(MFA)。This method supports Azure multi-factor authentication (MFA).
  • ActiveDirectoryMSI:受控服務識別(MSI)驗證。ActiveDirectoryMSI: Managed Service Identity (MSI) authentication. 若為使用者指派的身分識別,使用者識別碼應設定為使用者身分識別的物件識別碼。For a user-assigned identity, the user ID should be set to the object ID of the user identity.
  • SqlPassword: 使用使用者識別碼和密碼進行驗證。SqlPassword: Authentication using user ID and password.

  • 注意: 建議使用 SQL Server authentication 的應用程式將 Authentication 關鍵字(或其對應的屬性)的值設定為 SqlPassword,以啟用新的加密和憑證驗證行為NOTE: It's recommended that applications using SQL Server authentication set the value of the Authentication keyword (or its corresponding property) to SqlPassword to enable new encryption and certificate validation behavior.
自動轉譯Auto Translate SSPROP_INIT_AUTOTRANSLATESSPROP_INIT_AUTOTRANSLATE "AutoTranslate" 的同義字。Synonym for "AutoTranslate".
AutoTranslateAutoTranslate SSPROP_INIT_AUTOTRANSLATESSPROP_INIT_AUTOTRANSLATE 設定 OEM/ANSI 字元轉譯。Configures OEM/ANSI character translation. 可辨識的值為 "yes" 和 "no"。Recognized values are "yes" and "no".
[資料庫備份]Database DBPROP_INIT_CATALOGDBPROP_INIT_CATALOG 資料庫名稱。The database name.
DataTypeCompatibilityDataTypeCompatibility SSPROP_INIT_DATATYPECOMPATIBILITYSSPROP_INIT_DATATYPECOMPATIBILITY 指定要使用的資料類型處理模式。Specifies the mode of data type handling to use. 認得的值為 "0" (代表提供者資料類型) 和 "80" (代表 SQL Server 2000 資料類型)。Recognized values are "0" for provider data types and "80" for SQL Server 2000 data types.
加密t1Encrypt1 SSPROP_INIT_ENCRYPTSSPROP_INIT_ENCRYPT 指定當透過網路傳送資料以前,是否應該先加密資料。Specifies whether data should be encrypted before sending it over the network. 可能的值為 "yes" 和 "no"。Possible values are "yes" and "no". 預設值為 "no"。The default value is "no".
FailoverPartnerFailoverPartner SSPROP_INIT_FAILOVERPARTNERSSPROP_INIT_FAILOVERPARTNER 用於資料庫鏡像的容錯移轉伺服器名稱。The name of the failover server used for database mirroring.
FailoverPartnerSPNFailoverPartnerSPN SSPROP_INIT_FAILOVERPARTNERSPNSSPROP_INIT_FAILOVERPARTNERSPN 容錯移轉夥伴的 SPN。The SPN for the failover partner. 預設值為空字串。The default value is an empty string. 空字串會導致 SQL Server 的 OLE DB 驅動程式使用預設的提供者產生的 SPN。An empty string causes OLE DB Driver for SQL Server to use the default, provider-generated SPN.
語言Language SSPROPT_INIT_CURRENTLANGUAGESSPROPT_INIT_CURRENTLANGUAGE SQL ServerSQL Server 語言。The SQL ServerSQL Server language.
MarsConnMarsConn SSPROP_INIT_MARSCONNECTIONSSPROP_INIT_MARSCONNECTION 當伺服器為 SQL Server 2005 (9.x)SQL Server 2005 (9.x) 或更新版本時,啟用或停用連接上的 Multiple Active Result Sets (MARS)。Enables or disables multiple active result sets (MARS) on the connection if the server is SQL Server 2005 (9.x)SQL Server 2005 (9.x) or later. 可能的值為 "yes" 和 "no"。Possible values are "yes" and "no". 預設值為 "no"。The default value is "no".
MultiSubnetFailoverMultiSubnetFailover SSPROP_INIT_MULTISUBNETFAILOVERSSPROP_INIT_MULTISUBNETFAILOVER 在連接到 SQL ServerSQL Server 可用性群組的可用性群組接聽程式或 SQL ServerSQL Server 容錯移轉叢集執行個體時,一律指定 MultiSubnetFailover=yesAlways specify MultiSubnetFailover=Yes when connecting to the availability group listener of a SQL ServerSQL Server availability group or a SQL ServerSQL Server Failover Cluster Instance. MultiSubnetFailover=yes 會設定 OLE DB Driver for SQL Server ,以提供對 (目前) 使用中伺服器更快速的偵測與連接。MultiSubnetFailover=Yes configures OLE DB Driver for SQL Server to provide faster detection of and connection to the (currently) active server. 可能的值為 [是] 和 [否] 。Possible values are Yes and No. 預設值為 NoThe default is No. 例如:For example:

MultiSubnetFailover=Yes

如需 SQL Server 支援 AlwaysOn 可用性群組Always On availability groups OLE DB 驅動程式的詳細資訊,請參閱OLE DB 驅動程式,以取得高可用性、嚴重損壞修復的 SQL Server 支援For more information about OLE DB Driver for SQL Server's support for AlwaysOn 可用性群組Always On availability groups, see OLE DB Driver for SQL Server Support for High Availability, Disaster Recovery.
NetNet SSPROP_INIT_NETWORKLIBRARYSSPROP_INIT_NETWORKLIBRARY "Network" 的同義字。Synonym for "Network".
NetworkNetwork SSPROP_INIT_NETWORKLIBRARYSSPROP_INIT_NETWORKLIBRARY 用來建立組織中 SQL ServerSQL Server 執行個體之連接的網路程式庫。The network library used to establish a connection to an instance of SQL ServerSQL Server in the organization.
Network LibraryNetwork Library SSPROP_INIT_NETWORKLIBRARYSSPROP_INIT_NETWORKLIBRARY "Network" 的同義字。Synonym for "Network".
PacketSizePacketSize SSPROP_INIT_PACKETSIZESSPROP_INIT_PACKETSIZE 網路封包大小。Network packet size. 預設值是 4096。The default is 4096.
PersistSensitivePersistSensitive DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFODBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO 接受的值為 "yes" 和 "no" 字串。Accepts the strings "yes" and "no" as values. 當為 "no" 時,不允許使用資料來源物件來保存敏感性驗證資訊。When "no", the data source object is not allowed to persist sensitive authentication information
PWDPWD DBPROP_AUTH_PASSWORDDBPROP_AUTH_PASSWORD SQL ServerSQL Server 登入密碼。The SQL ServerSQL Server login password.
ServerServer DBPROP_INIT_DATASOURCEDBPROP_INIT_DATASOURCE SQL ServerSQL Server 執行個體的名稱。The name of a SQL ServerSQL Server instance. 此值必須是網路上的伺服器名稱、IP 位址,或是 SQL ServerSQL Server 組態管理員別名的名稱。The value must be either the name of a server on the network, an IP address, or the name of a SQL ServerSQL Server Configuration Manager alias.

如果沒有指定,就會連接至本機電腦上的預設執行個體。When not specified, a connection is made to the default instance on the local computer.

Address關鍵字會覆寫Server關鍵字。The Address keyword overrides the Server keyword.

您可藉由指定下列其中一個項目,連接到本機伺服器上的預設執行個體:You can connect to the default instance on the local server by specifying one of the following:

伺服器=;Server=;

伺服器=.;Server=.;

伺服器=(local);Server=(local);

伺服器=(local);Server=(local);

伺服器=(localhost);Server=(localhost);

伺服器=(localdb)\ 執行個體名稱 ;Server=(localdb)\ instancename ;

如需 LocalDB 支援的詳細資訊,請參閱OLE DB 驅動程式以取得 localdb 的 SQL Server 支援For more information about LocalDB support, see OLE DB Driver for SQL Server Support for LocalDB.

若要指定的具名執行個體SQL ServerSQL Server,附加 \ InstanceNameTo specify a named instance of SQL ServerSQL Server, append \InstanceName.

如果未指定伺服器,就會連接到本機電腦上的預設執行個體。When no server is specified, a connection is made to the default instance on the local computer.

若您指定 IP 位址,請確定在 SQL ServerSQL Server 組態管理員中已啟用 TCP/IP 或具名管道通訊協定。If you specify an IP address, make sure that the TCP/IP or named pipes protocols are enabled in SQL ServerSQL Server Configuration Manager.

Server 關鍵字的完整語法如下:The complete syntax for the Server keyword is as follows:

伺服器= [通訊協定 : ]伺服器[ , 連接埠]Server=[protocol:]Server[,port]

protocol 可以是 tcp (TCP/IP)、 lpc (共用記憶體) 或 np (具名管道)。protocol can be tcp (TCP/IP), lpc (shared memory), or np (named pipes).

下列是指定具名管道的範例:The following is an example of specifying a named pipe:

np:\\.\pipe\MSSQL$MYINST01\sql\query

此程式碼行指定具名管道通訊協定、本機電腦上的具名管道 (\\.\pipe)、SQL ServerSQL Server 執行個體的名稱 (MSSQL$MYINST01) 以及具名管道的預設名稱 (sql/query)。This line specifies named pipe protocol, a named pipe on the local machine (\\.\pipe), the name of the SQL ServerSQL Server instance (MSSQL$MYINST01), and the default name of the named pipe (sql/query).

如果未指定通訊協定網路關鍵字,SQL Server 的 OLE DB 驅動程式會使用 SQL ServerSQL Server Configuration Manager 中指定的通訊協定順序。If neither a protocol nor the Network keyword is specified, OLE DB Driver for SQL Server will use the protocol order specified in SQL ServerSQL Server Configuration Manager.

port 是在指定伺服器上所要連接的通訊埠。port is the port to connect to, on the specified server. 根據預設,SQL ServerSQL Server 會使用通訊埠 1433。By default, SQL ServerSQL Server uses port 1433.

使用 SQL Server 的 OLE DB 驅動程式時,在連接字串中傳遞至伺服器的值開頭會忽略空格。Spaces are ignored at the beginning of the value passed to Server in connection strings when using OLE DB Driver for SQL Server.
ServerSPNServerSPN SSPROP_INIT_SERVERSPNSSPROP_INIT_SERVERSPN 伺服器的 SPN。The SPN for the server. 預設值為空字串。The default value is an empty string. 空字串會導致 SQL Server 的 OLE DB 驅動程式使用預設的提供者產生的 SPN。An empty string causes OLE DB Driver for SQL Server to use the default, provider-generated SPN.
逾時Timeout DBPROP_INIT_TIMEOUTDBPROP_INIT_TIMEOUT 等候資料來源初始化完成的時間量 (以秒為單位)。The amount of time (in seconds) to wait for data source initialization to complete.
Trusted_ConnectionTrusted_Connection DBPROP_AUTH_INTEGRATEDDBPROP_AUTH_INTEGRATED 當為 "yes" 時,會指示 SQL Server 的 OLE DB 驅動程式使用 Windows 驗證模式進行登入驗證。When "yes", instructs the OLE DB Driver for SQL Server to use Windows Authentication Mode for login validation. 否則會指示 OLE DB Driver for SQL Server 使用 SQL ServerSQL Server 使用者名稱和密碼進行登入驗證,而且必須指定 UID 和 PWD 密碼。Otherwise instructs the OLE DB Driver for SQL Server to use a SQL ServerSQL Server username and password for login validation, and the UID and PWD keywords must be specified.
TrustServerCertificate1TrustServerCertificate1 SSPROP_INIT_TRUST_SERVER_CERTIFICATESSPROP_INIT_TRUST_SERVER_CERTIFICATE 接受的值為 "yes" 和 "no" 字串。Accepts the strings "yes" and "no" as values. 預設值為 "no",這表示將會驗證伺服器憑證。The default value is "no", which means that the server certificate will be validated.
UIDUID DBPROP_AUTH_USERIDDBPROP_AUTH_USERID SQL ServerSQL Server 登入名稱。The SQL ServerSQL Server login name.
UseFMTONLYUseFMTONLY SSPROP_INIT_USEFMTONLYSSPROP_INIT_USEFMTONLY 控制連線到 SQL Server 2012 (11.x)SQL Server 2012 (11.x) 及更新版本時,如何擷取中繼資料。Controls how metadata is retrieved when connecting to SQL Server 2012 (11.x)SQL Server 2012 (11.x) and newer. 可能的值為 "yes" 和 "no"。Possible values are "yes" and "no". 預設值為 "no"。The default value is "no".

根據預設,SQL Server 的 OLE DB 驅動程式會使用sp_describe_first_result_setsp_describe_undeclared_parameters預存程式來取得中繼資料。By default, the OLE DB Driver for SQL Server uses sp_describe_first_result_set and sp_describe_undeclared_parameters stored procedures to retrieve metadata. 這些預存程式有一些限制(例如,在臨時表上操作時,它們會失敗)。These stored procedures have some limitations (e.g. they will fail when operating on temporary tables). UseFMTONLY設定為 [是],會指示驅動程式改為使用SET set fmtonly來進行中繼資料抓取。Setting UseFMTONLY to "yes" instructs the driver to use SET FMTONLY for metadata retrieval instead.
UseProcForPrepareUseProcForPrepare SSPROP_INIT_USEPROCFORPREPSSPROP_INIT_USEPROCFORPREP 這個關鍵字已被取代,而 SQL Server 的 OLE DB 驅動程式會忽略它的設定。This keyword is deprecated, and its setting is ignored by the OLE DB Driver for SQL Server.
WSIDWSID SSPROP_INIT_WSIDSSPROP_INIT_WSID 工作站識別碼。The workstation identifier.

[1]:若要改善安全性,使用驗證/存取權杖初始化屬性或其對應的連接字串關鍵字時,會修改加密和憑證驗證行為。[1]: To improve security, encryption and certificate validation behavior is modified when using Authentication/Access Token initialization properties or their corresponding connection string keywords. 如需詳細資訊,請參閱加密和憑證驗證For details, see Encryption and certificate validation.

OLE DB 應用程式使用的連接字串如果使用 IDataInitialize::GetDataSource,其語法如下:Connection strings used by OLE DB applications using IDataInitialize::GetDataSource have the following syntax:

connection-string ::= empty-string[;] | attribute[;] | attribute; connection-string

empty-string ::=

attribute ::= attribute-keyword=[quote]attribute-value[quote]

attribute-value ::= character-string

attribute-keyword ::= identifier

quote ::= " | '

屬性的使用必須符合其範圍內所允許的語法。 例如,WSID 會使用大括號 ( {} ) 字元,而 Application Name 會使用單引號 ( ' ) 或雙引號 ( " ) 字元。 只有字串屬性可以加上引號。Only string properties can be quoted. 嘗試將整數或列舉屬性加上引號將會產生「連接字串沒有符合 OLE DB 規格」錯誤。Attempting to quote an integer or enumerated property will result in a "Connection String does not conform to OLE DB specification" error.

您可以選擇用單引號或雙引號括住屬性值,這樣是很好的作法。Attribute values can optionally be enclosed in single or double quotes, and it is good practice to do so. 如此可在值包含非英數字元時避免問題發生。This avoids problems when values contain non-alphanumeric characters. 使用的引號字元也可出現在值當中,但前提必須是雙引號字元。The quote character used can also appear in values, provided that it is doubled.

連接字串關鍵字 = 符號後面的空格字元應該解譯為常值,即使該值括在引號內也是如此。A space character after the = sign of a connection string keyword will be interpreted as a literal, even if the value is enclosed in quotation marks.

如果連接字串具有下表所列的多個屬性,將會使用最後一個屬性的值。If a connection string has more than one of the properties listed in the following table, the value of the last property will be used.

下表說明可搭配 IDataInitialize::GetDataSource 使用的關鍵字:The following table describes the keywords that may be used with IDataInitialize::GetDataSource:

關鍵字Keyword 初始化屬性Initialization property DescriptionDescription
存取權杖1Access Token1 SSPROP_AUTH_ACCESS_TOKENSSPROP_AUTH_ACCESS_TOKEN 用來驗證 Azure Active Directory 的存取權杖。The access token used to authenticate to Azure Active Directory.

注意: 指定此關鍵字並同時 UIDPWDTrusted_ConnectionAuthentication 連接字串關鍵字或其對應的屬性/關鍵字是錯誤。NOTE: It's an error to specify this keyword and also UID, PWD, Trusted_Connection, or Authentication connection string keywords or their corresponding properties/keywords.
Application NameApplication Name SSPROP_INIT_APPNAMESSPROP_INIT_APPNAME 識別應用程式的字串。The string identifying the application.
Application IntentApplication Intent SSPROP_INIT_APPLICATIONINTENTSSPROP_INIT_APPLICATIONINTENT 宣告連接到伺服器時的應用程式工作負載類型。Declares the application workload type when connecting to a server. 可能的值為 ReadOnlyReadWritePossible values are ReadOnly and ReadWrite.

預設值為ReadWriteThe default is ReadWrite. 如需 SQL Server 支援 AlwaysOn 可用性群組Always On availability groups OLE DB 驅動程式的詳細資訊,請參閱OLE DB 驅動程式,以取得高可用性、嚴重損壞修復的 SQL Server 支援For more information about OLE DB Driver for SQL Server's support for AlwaysOn 可用性群組Always On availability groups, see OLE DB Driver for SQL Server Support for High Availability, Disaster Recovery.
驗證1Authentication1 SSPROP_AUTH_MODESSPROP_AUTH_MODE 指定使用的 SQL 或 Active Directory 驗證。Specifies the SQL or Active Directory authentication used. 有效值為:Valid values are:
  • (not set):由其他關鍵字決定的驗證模式。(not set): Authentication mode determined by other keywords.
  • 使用 Azure Active Directory 身分識別 ActiveDirectoryPassword:User 識別碼和密碼驗證。ActiveDirectoryPassword:User ID and password authentication with an Azure Active Directory identity.
  • 使用 Azure Active Directory 身分識別 ActiveDirectoryIntegrated: 整合式驗證。ActiveDirectoryIntegrated: Integrated authentication with an Azure Active Directory identity.

  • 注意: ActiveDirectoryIntegrated 關鍵字也可以用於 Windows 驗證以 SQL Server。NOTE: The ActiveDirectoryIntegrated keyword can also be used for Windows authentication to SQL Server. 它會取代 Integrated Security (或 Trusted_Connection)驗證關鍵字。It replaces Integrated Security (or Trusted_Connection) authentication keywords. 建議使用 Integrated Security (或 Trusted_Connection)關鍵字或其對應屬性的應用程式將 Authentication 關鍵字的值(或其對應的屬性)設定為 ActiveDirectoryIntegrated,以啟用新的加密和憑證驗證行為.It's recommended that applications using Integrated Security (or Trusted_Connection) keywords or their corresponding properties set the value of the Authentication keyword (or its corresponding property) to ActiveDirectoryIntegrated to enable new encryption and certificate validation behavior.

  • ActiveDirectoryInteractive: 具有 Azure Active Directory 身分識別的互動式驗證。ActiveDirectoryInteractive: Interactive authentication with an Azure Active Directory identity. 這個方法支援 Azure 多重要素驗證(MFA)。This method supports Azure multi-factor authentication (MFA).
  • ActiveDirectoryMSI:受控服務識別(MSI)驗證。ActiveDirectoryMSI: Managed Service Identity (MSI) authentication. 若為使用者指派的身分識別,使用者識別碼應設定為使用者身分識別的物件識別碼。For a user-assigned identity, the user ID should be set to the object ID of the user identity.
  • SqlPassword: 使用使用者識別碼和密碼進行驗證。SqlPassword: Authentication using user ID and password.

  • 注意: 建議使用 SQL Server authentication 的應用程式將 Authentication 關鍵字(或其對應的屬性)的值設定為 SqlPassword,以啟用新的加密和憑證驗證行為NOTE: It's recommended that applications using SQL Server authentication set the value of the Authentication keyword (or its corresponding property) to SqlPassword to enable new encryption and certificate validation behavior.
自動轉譯Auto Translate SSPROP_INIT_AUTOTRANSLATESSPROP_INIT_AUTOTRANSLATE "AutoTranslate" 的同義字。Synonym for "AutoTranslate".
AutoTranslateAutoTranslate SSPROP_INIT_AUTOTRANSLATESSPROP_INIT_AUTOTRANSLATE 設定 OEM/ANSI 字元轉譯。Configures OEM/ANSI character translation. 認得的值為 "true" 和 "false"。Recognized values are "true" and "false".
連接逾時Connect Timeout DBPROP_INIT_TIMEOUTDBPROP_INIT_TIMEOUT 等候資料來源初始化完成的時間量 (以秒為單位)。The amount of time (in seconds) to wait for data source initialization to complete.
Current LanguageCurrent Language SSPROPT_INIT_CURRENTLANGUAGESSPROPT_INIT_CURRENTLANGUAGE SQL ServerSQL Server 語言名稱。The SQL ServerSQL Server language name.
資料來源Data Source DBPROP_INIT_DATASOURCEDBPROP_INIT_DATASOURCE 組織中 SQL ServerSQL Server 執行個體的名稱。The name of an instance of SQL ServerSQL Server in the organization.

如果沒有指定,就會連接至本機電腦上的預設執行個體。When not specified, a connection is made to the default instance on the local computer.

如需有關有效位址語法的詳細資訊,請參閱本主題中對於 Server 關鍵字的說明。For more information about valid address syntax, see the description of the Server keyword, in this topic.
DataTypeCompatibilityDataTypeCompatibility SSPROP_INIT_DATATYPECOMPATIBILITYSSPROP_INIT_DATATYPECOMPATIBILITY 指定要使用的資料類型處理模式。Specifies the mode of data type handling to use. 認得的值為 "0" (代表提供者資料類型) 和 "80" (代表 SQL Server 2000 (8.x)SQL Server 2000 (8.x) 資料類型)。Recognized values are "0" for provider data types and "80" for SQL Server 2000 (8.x)SQL Server 2000 (8.x) data types.
Failover PartnerFailover Partner SSPROP_INIT_FAILOVERPARTNERSSPROP_INIT_FAILOVERPARTNER 用於資料庫鏡像的容錯移轉伺服器名稱。The name of the failover server used for database mirroring.
Failover Partner SPNFailover Partner SPN SSPROP_INIT_FAILOVERPARTNERSPNSSPROP_INIT_FAILOVERPARTNERSPN 容錯移轉夥伴的 SPN。The SPN for the failover partner. 預設值為空字串。The default value is an empty string. 空字串會導致 SQL Server 的 OLE DB 驅動程式使用預設的提供者產生的 SPN。An empty string causes OLE DB Driver for SQL Server to use the default, provider-generated SPN.
初始目錄Initial Catalog DBPROP_INIT_CATALOGDBPROP_INIT_CATALOG 資料庫名稱。The database name.
初始檔案名稱Initial File Name SSPROP_INIT_FILENAMESSPROP_INIT_FILENAME 可附加資料庫的主要檔案名稱,包括完整路徑名稱。The name of the primary file (include the full path name) of an attachable database. 若要使用 AttachDBFileName,您還必須使用提供者字串 DATABASE 關鍵字來指定資料庫名稱。To use AttachDBFileName, you must also specify the database name with the provider string DATABASE keyword. 如果之前已附加資料庫,SQL ServerSQL Server 不會重新附加它 (它會使用附加的資料庫當做連接的預設值)。If the database was previously attached, SQL ServerSQL Server does not reattach it (it uses the attached database as the default for the connection).
整合式安全性Integrated Security DBPROP_AUTH_INTEGRATEDDBPROP_AUTH_INTEGRATED 接受 "SSPI" 值進行 Windows 驗證。Accepts the value "SSPI" for Windows Authentication.
MARS ConnectionMARS Connection SSPROP_INIT_MARSCONNECTIONSSPROP_INIT_MARSCONNECTION 啟用或停用連接上的 Multiple Active Result Sets (MARS)。Enables or disables multiple active result sets (MARS) on the connection. 認得的值為 "true" 和 "false"。Recognized values are "true" and "false". 預設值為 "false"。The default is "false".
MultiSubnetFailoverMultiSubnetFailover SSPROP_INIT_MULTISUBNETFAILOVERSSPROP_INIT_MULTISUBNETFAILOVER 在連接到 SQL ServerSQL Server 可用性群組的可用性群組接聽程式或 SQL ServerSQL Server 容錯移轉叢集執行個體時,一律指定 MultiSubnetFailover=TrueAlways specify MultiSubnetFailover=True when connecting to the availability group listener of a SQL ServerSQL Server availability group or a SQL ServerSQL Server Failover Cluster Instance. MultiSubnetFailover=True 會設定 OLE DB Driver for SQL Server ,以提供對 (目前) 使用中伺服器更快速的偵測與連線。MultiSubnetFailover=True configures OLE DB Driver for SQL Server to provide faster detection of and connection to the (currently) active server. 可能的值為 TrueFalsePossible values are True and False. 預設值為 FalseThe default is False. 例如:For example:

MultiSubnetFailover=True

如需 SQL Server 支援 AlwaysOn 可用性群組Always On availability groups OLE DB 驅動程式的詳細資訊,請參閱OLE DB 驅動程式,以取得高可用性、嚴重損壞修復的 SQL Server 支援For more information about OLE DB Driver for SQL Server's support for AlwaysOn 可用性群組Always On availability groups, see OLE DB Driver for SQL Server Support for High Availability, Disaster Recovery.
Network AddressNetwork Address SSPROP_INIT_NETWORKADDRESSSSPROP_INIT_NETWORKADDRESS 組織中 SQL ServerSQL Server 執行個體的網路位址。The network address of an instance of SQL ServerSQL Server in the organization.

如需有關有效位址語法的詳細資訊,請參閱本主題中對於 Address 關鍵字的說明。For more information about valid address syntax, see the description of the Address keyword, in this topic.
Network LibraryNetwork Library SSPROP_INIT_NETWORKLIBRARYSSPROP_INIT_NETWORKLIBRARY 用來建立組織中 SQL ServerSQL Server 執行個體之連接的網路程式庫。The network library used to establish a connection to an instance of SQL ServerSQL Server in the organization.
封包大小Packet Size SSPROP_INIT_PACKETSIZESSPROP_INIT_PACKETSIZE 網路封包大小。Network packet size. 預設值是 4096。The default is 4096.
密碼Password DBPROP_AUTH_PASSWORDDBPROP_AUTH_PASSWORD SQL ServerSQL Server 登入密碼。The SQL ServerSQL Server login password.
保存安全性資訊Persist Security Info DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFODBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO 接受的值為 "true" 和 "false" 字串。Accepts the strings "true" and "false" as values. 當為 "false" 時,不允許使用資料來源物件來保存敏感性驗證資訊。When "false", the data source object is not allowed to persist sensitive authentication information
提供者Provider 針對 SQL Server 的 OLE DB 驅動程式,這應該是 "內含 MSOLEDBSQL.H"。For OLE DB Driver for SQL Server, this should be "MSOLEDBSQL".
Server SPNServer SPN SSPROP_INIT_SERVERSPNSSPROP_INIT_SERVERSPN 伺服器的 SPN。The SPN for the server. 預設值為空字串。The default value is an empty string. 空字串會導致 SQL Server 的 OLE DB 驅動程式使用預設的提供者產生的 SPN。An empty string causes OLE DB Driver for SQL Server to use the default, provider-generated SPN.
信任伺服器憑證1Trust Server Certificate1 SSPROP_INIT_TRUST_SERVER_CERTIFICATESSPROP_INIT_TRUST_SERVER_CERTIFICATE 接受的值為 "true" 和 "false" 字串。Accepts the strings "true" and "false" as values. 預設值為 "false",這表示將會驗證伺服器憑證。The default value is "false", which means that the server certificate will be validated.
為資料使用加密1Use Encryption for Data1 SSPROP_INIT_ENCRYPTSSPROP_INIT_ENCRYPT 指定當透過網路傳送資料以前,是否應該先加密資料。Specifies whether data should be encrypted before sending it over the network. 可能的值為 "true" 和 "false"。Possible values are "true" and "false". 預設值為 "false"。The default value is "false".
Use FMTONLYUse FMTONLY SSPROP_INIT_USEFMTONLYSSPROP_INIT_USEFMTONLY 控制連線到 SQL Server 2012 (11.x)SQL Server 2012 (11.x) 及更新版本時,如何擷取中繼資料。Controls how metadata is retrieved when connecting to SQL Server 2012 (11.x)SQL Server 2012 (11.x) and newer. 可能的值為 "true" 和 "false"。Possible values are "true" and "false". 預設值為 "false"。The default value is "false".

根據預設,SQL Server 的 OLE DB 驅動程式會使用sp_describe_first_result_setsp_describe_undeclared_parameters預存程式來取得中繼資料。By default, the OLE DB Driver for SQL Server uses sp_describe_first_result_set and sp_describe_undeclared_parameters stored procedures to retrieve metadata. 這些預存程式有一些限制(例如,在臨時表上操作時,它們會失敗)。These stored procedures have some limitations (e.g. they will fail when operating on temporary tables). 將 [使用 set fmtonly ] 設定為 "true",會指示驅動程式改為使用SET set fmtonly來進行中繼資料抓取。Setting Use FMTONLY to "true" instructs the driver to use SET FMTONLY for metadata retrieval instead.
使用者識別碼User ID DBPROP_AUTH_USERIDDBPROP_AUTH_USERID SQL ServerSQL Server 登入名稱。The SQL ServerSQL Server login name.
Workstation IDWorkstation ID SSPROP_INIT_WSIDSSPROP_INIT_WSID 工作站識別碼。The workstation identifier.

[1]:若要改善安全性,使用驗證/存取權杖初始化屬性或其對應的連接字串關鍵字時,會修改加密和憑證驗證行為。[1]: To improve security, encryption and certificate validation behavior is modified when using Authentication/Access Token initialization properties or their corresponding connection string keywords. 如需詳細資訊,請參閱加密和憑證驗證For details, see Encryption and certificate validation.

請注意:在此連接字串中,"Old Password" 屬性會設定 SSPROP_AUTH_OLD_PASSWORD,這是無法透過提供者字串屬性取得的目前密碼 (可能已過期)。Note In the connection string, the "Old Password" property sets SSPROP_AUTH_OLD_PASSWORD, which is the current (possibly expired) password that is not available via a provider string property.

ActiveX Data Objects (ADO) 連接字串關鍵字ActiveX Data Objects (ADO) Connection String Keywords

ADO 應用程式會設定 ADODBConnection 物件的 ConnectionString 屬性,或是提供連接字串當做 ADODBConnection 物件之 Open 方法的參數。ADO applications set the ConnectionString property of ADODBConnection objects or supply a connection string as a parameter to the Open method of ADODBConnection objects.

ADO 應用程式也可以使用 OLE DB IDBInitialize::Initialize 方法所使用的關鍵字,但是只適用於沒有預設值的屬性。ADO applications can also use the keywords used by the OLE DB IDBInitialize::Initialize method, but only for properties that do not have a default value. 如果應用程式在初始化字串中同時使用 ADO 關鍵字和 IDBInitialize::Initialize 關鍵字,將會使用 ADO 關鍵字設定。If an application uses both the ADO keywords and the IDBInitialize::Initialize keywords in the initialization string, the ADO keyword setting will be used. 強烈建議您只讓應用程式使用 ADO 連接字串關鍵字。It is strongly recommended that applications only use ADO connection string keywords.

ADO 使用的連接字串具有以下語法:Connection strings used by ADO have the following syntax:

connection-string ::= empty-string[;] | attribute[;] | attribute; connection-string

empty-string ::=

attribute ::= attribute-keyword=["]attribute-value["]

attribute-value ::= character-string

attribute-keyword ::= identifier

可以選擇用雙引號括住屬性值,這樣是很好的作法。Attribute values can optionally be enclosed in double quotes, and it is good practice to do so. 如此可在值包含非英數字元時避免問題發生。This avoids problems when values contain non-alphanumeric characters. 屬性值不能包含雙引號。Attribute values cannot contain double quotes.

下表描述可搭配 ADO 連接字串使用的關鍵字:The following table describes the keywords that may be used with an ADO connection string:

關鍵字Keyword 初始化屬性Initialization property DescriptionDescription
存取權杖1Access Token1 SSPROP_AUTH_ACCESS_TOKENSSPROP_AUTH_ACCESS_TOKEN 用來驗證 Azure Active Directory 的存取權杖。The access token used to authenticate to Azure Active Directory.

注意: 指定此關鍵字並同時 UIDPWDTrusted_ConnectionAuthentication 連接字串關鍵字或其對應的屬性/關鍵字是錯誤。NOTE: It's an error to specify this keyword and also UID, PWD, Trusted_Connection, or Authentication connection string keywords or their corresponding properties/keywords.
Application IntentApplication Intent SSPROP_INIT_APPLICATIONINTENTSSPROP_INIT_APPLICATIONINTENT 宣告連接到伺服器時的應用程式工作負載類型。Declares the application workload type when connecting to a server. 可能的值為 ReadOnlyReadWritePossible values are ReadOnly and ReadWrite.

預設值為ReadWriteThe default is ReadWrite. 如需 SQL Server 支援 AlwaysOn 可用性群組Always On availability groups OLE DB 驅動程式的詳細資訊,請參閱OLE DB 驅動程式,以取得高可用性、嚴重損壞修復的 SQL Server 支援For more information about OLE DB Driver for SQL Server's support for AlwaysOn 可用性群組Always On availability groups, see OLE DB Driver for SQL Server Support for High Availability, Disaster Recovery.
Application NameApplication Name SSPROP_INIT_APPNAMESSPROP_INIT_APPNAME 識別應用程式的字串。The string identifying the application.
驗證1Authentication1 SSPROP_AUTH_MODESSPROP_AUTH_MODE 指定使用的 SQL 或 Active Directory 驗證。Specifies the SQL or Active Directory authentication used. 有效值為:Valid values are:
  • (not set):由其他關鍵字決定的驗證模式。(not set): Authentication mode determined by other keywords.
  • 使用 Azure Active Directory 身分識別 ActiveDirectoryPassword:User 識別碼和密碼驗證。ActiveDirectoryPassword:User ID and password authentication with an Azure Active Directory identity.
  • 使用 Azure Active Directory 身分識別 ActiveDirectoryIntegrated: 整合式驗證。ActiveDirectoryIntegrated: Integrated authentication with an Azure Active Directory identity.

  • 注意: ActiveDirectoryIntegrated 關鍵字也可以用於 Windows 驗證以 SQL Server。NOTE: The ActiveDirectoryIntegrated keyword can also be used for Windows authentication to SQL Server. 它會取代 Integrated Security (或 Trusted_Connection)驗證關鍵字。It replaces Integrated Security (or Trusted_Connection) authentication keywords. 建議使用 Integrated Security (或 Trusted_Connection)關鍵字或其對應屬性的應用程式將 Authentication 關鍵字的值(或其對應的屬性)設定為 ActiveDirectoryIntegrated,以啟用新的加密和憑證驗證行為.It's recommended that applications using Integrated Security (or Trusted_Connection) keywords or their corresponding properties set the value of the Authentication keyword (or its corresponding property) to ActiveDirectoryIntegrated to enable new encryption and certificate validation behavior.

  • ActiveDirectoryInteractive: 具有 Azure Active Directory 身分識別的互動式驗證。ActiveDirectoryInteractive: Interactive authentication with an Azure Active Directory identity. 這個方法支援 Azure 多重要素驗證(MFA)。This method supports Azure multi-factor authentication (MFA).
  • ActiveDirectoryMSI:受控服務識別(MSI)驗證。ActiveDirectoryMSI: Managed Service Identity (MSI) authentication. 若為使用者指派的身分識別,使用者識別碼應設定為使用者身分識別的物件識別碼。For a user-assigned identity, the user ID should be set to the object ID of the user identity.
  • SqlPassword: 使用使用者識別碼和密碼進行驗證。SqlPassword: Authentication using user ID and password.

  • 注意: 建議使用 SQL Server authentication 的應用程式將 Authentication 關鍵字(或其對應的屬性)的值設定為 SqlPassword,以啟用新的加密和憑證驗證行為NOTE: It's recommended that applications using SQL Server authentication set the value of the Authentication keyword (or its corresponding property) to SqlPassword to enable new encryption and certificate validation behavior.
自動轉譯Auto Translate SSPROP_INIT_AUTOTRANSLATESSPROP_INIT_AUTOTRANSLATE "AutoTranslate" 的同義字。Synonym for "AutoTranslate".
AutoTranslateAutoTranslate SSPROP_INIT_AUTOTRANSLATESSPROP_INIT_AUTOTRANSLATE 設定 OEM/ANSI 字元轉譯。Configures OEM/ANSI character translation. 認得的值為 "true" 和 "false"。Recognized values are "true" and "false".
連接逾時Connect Timeout DBPROP_INIT_TIMEOUTDBPROP_INIT_TIMEOUT 等候資料來源初始化完成的時間量 (以秒為單位)。The amount of time (in seconds) to wait for data source initialization to complete.
Current LanguageCurrent Language SSPROPT_INIT_CURRENTLANGUAGESSPROPT_INIT_CURRENTLANGUAGE SQL ServerSQL Server 語言名稱。The SQL ServerSQL Server language name.
資料來源Data Source DBPROP_INIT_DATASOURCEDBPROP_INIT_DATASOURCE 組織中 SQL ServerSQL Server 執行個體的名稱。The name of an instance of SQL ServerSQL Server in the organization.

如果沒有指定,就會連接至本機電腦上的預設執行個體。When not specified, a connection is made to the default instance on the local computer.

如需有關有效位址語法的詳細資訊,請參閱本主題中對於 Server 關鍵字的說明。For more information about valid address syntax, see the description of the Server keyword, in this topic.
DataTypeCompatibilityDataTypeCompatibility SSPROP_INIT_DATATYPECOMPATIBILITYSSPROP_INIT_DATATYPECOMPATIBILITY 指定即將使用之資料類型處理的模式。Specifies the mode of data type handling that will be used. 認得的值為 "0" (代表提供者資料類型) 和 "80" (代表 SQL Server 2000 資料類型)。Recognized values are "0" for provider data types and "80" for SQL Server 2000 data types.
Failover PartnerFailover Partner SSPROP_INIT_FAILOVERPARTNERSSPROP_INIT_FAILOVERPARTNER 用於資料庫鏡像的容錯移轉伺服器名稱。The name of the failover server used for database mirroring.
Failover Partner SPNFailover Partner SPN SSPROP_INIT_FAILOVERPARTNERSPNSSPROP_INIT_FAILOVERPARTNERSPN 容錯移轉夥伴的 SPN。The SPN for the failover partner. 預設值為空字串。The default value is an empty string. 空字串會導致 SQL Server 的 OLE DB 驅動程式使用預設的提供者產生的 SPN。An empty string causes OLE DB Driver for SQL Server to use the default, provider-generated SPN.
初始目錄Initial Catalog DBPROP_INIT_CATALOGDBPROP_INIT_CATALOG 資料庫名稱。The database name.
初始檔案名稱Initial File Name SSPROP_INIT_FILENAMESSPROP_INIT_FILENAME 可附加資料庫的主要檔案名稱,包括完整路徑名稱。The name of the primary file (include the full path name) of an attachable database. 若要使用 AttachDBFileName,您還必須使用提供者字串 DATABASE 關鍵字來指定資料庫名稱。To use AttachDBFileName, you must also specify the database name with the provider string DATABASE keyword. 如果之前已附加資料庫,SQL ServerSQL Server 不會重新附加它 (它會使用附加的資料庫當做連接的預設值)。If the database was previously attached, SQL ServerSQL Server does not reattach it (it uses the attached database as the default for the connection).
整合式安全性Integrated Security DBPROP_AUTH_INTEGRATEDDBPROP_AUTH_INTEGRATED 接受 "SSPI" 值進行 Windows 驗證。Accepts the value "SSPI" for Windows Authentication.
MARS ConnectionMARS Connection SSPROP_INIT_MARSCONNECTIONSSPROP_INIT_MARSCONNECTION 當伺服器為 SQL Server 2005 (9.x)SQL Server 2005 (9.x) 或更新版本時,啟用或停用連接上的 Multiple Active Result Sets (MARS)。Enables or disables multiple active result sets (MARS) on the connection if the server is SQL Server 2005 (9.x)SQL Server 2005 (9.x) or later. 認得的值為 "true" 和 "false"。預設值是 "false"。Recognized values are "true" and "false".The default is "false".
MultiSubnetFailoverMultiSubnetFailover SSPROP_INIT_MULTISUBNETFAILOVERSSPROP_INIT_MULTISUBNETFAILOVER 在連接到 SQL ServerSQL Server 可用性群組的可用性群組接聽程式或 SQL ServerSQL Server 容錯移轉叢集執行個體時,一律指定 MultiSubnetFailover=TrueAlways specify MultiSubnetFailover=True when connecting to the availability group listener of a SQL ServerSQL Server availability group or a SQL ServerSQL Server Failover Cluster Instance. MultiSubnetFailover=True 會設定 OLE DB Driver for SQL Server ,以提供對 (目前) 使用中伺服器更快速的偵測與連線。MultiSubnetFailover=True configures OLE DB Driver for SQL Server to provide faster detection of and connection to the (currently) active server. 可能的值為 TrueFalsePossible values are True and False. 預設值為 FalseThe default is False. 例如:For example:

MultiSubnetFailover=True

如需 SQL Server 支援 AlwaysOn 可用性群組Always On availability groups OLE DB 驅動程式的詳細資訊,請參閱OLE DB 驅動程式,以取得高可用性、嚴重損壞修復的 SQL Server 支援For more information about OLE DB Driver for SQL Server's support for AlwaysOn 可用性群組Always On availability groups, see OLE DB Driver for SQL Server Support for High Availability, Disaster Recovery.
Network AddressNetwork Address SSPROP_INIT_NETWORKADDRESSSSPROP_INIT_NETWORKADDRESS 組織中 SQL ServerSQL Server 執行個體的網路位址。The network address of an instance of SQL ServerSQL Server in the organization.

如需有關有效位址語法的詳細資訊,請參閱本主題中對於 Address 關鍵字的說明。For more information about valid address syntax, see the description of the Address keyword, in this topic.
Network LibraryNetwork Library SSPROP_INIT_NETWORKLIBRARYSSPROP_INIT_NETWORKLIBRARY 用來建立組織中 SQL ServerSQL Server 執行個體之連接的網路程式庫。The network library used to establish a connection to an instance of SQL ServerSQL Server in the organization.
封包大小Packet Size SSPROP_INIT_PACKETSIZESSPROP_INIT_PACKETSIZE 網路封包大小。Network packet size. 預設值是 4096。The default is 4096.
密碼Password DBPROP_AUTH_PASSWORDDBPROP_AUTH_PASSWORD SQL ServerSQL Server 登入密碼。The SQL ServerSQL Server login password.
保存安全性資訊Persist Security Info DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFODBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO 接受的值為 "true" 和 "false" 字串。Accepts the strings "true" and "false" as values. 如果為 "false",表示不允許資料來源物件保存機密的驗證資訊。When "false" the data source object is not allowed to persist sensitive authentication information.
提供者Provider 針對 SQL Server 的 OLE DB 驅動程式,這應該是 "內含 MSOLEDBSQL.H"。For OLE DB Driver for SQL Server, this should be "MSOLEDBSQL".
Server SPNServer SPN SSPROP_INIT_SERVERSPNSSPROP_INIT_SERVERSPN 伺服器的 SPN。The SPN for the server. 預設值為空字串。The default value is an empty string. 空字串會導致 SQL Server 的 OLE DB 驅動程式使用預設的提供者產生的 SPN。An empty string causes OLE DB Driver for SQL Server to use the default, provider-generated SPN.
信任伺服器憑證1Trust Server Certificate1 SSPROP_INIT_TRUST_SERVER_CERTIFICATESSPROP_INIT_TRUST_SERVER_CERTIFICATE 接受的值為 "true" 和 "false" 字串。Accepts the strings "true" and "false" as values. 預設值為 "false",這表示將會驗證伺服器憑證。The default value is "false", which means that the server certificate will be validated.
為資料使用加密1Use Encryption for Data1 SSPROP_INIT_ENCRYPTSSPROP_INIT_ENCRYPT 指定當透過網路傳送資料以前,是否應該先加密資料。Specifies whether data should be encrypted before sending it over the network. 可能的值為 "true" 和 "false"。Possible values are "true" and "false". 預設值為 "false"。The default value is "false".
Use FMTONLYUse FMTONLY SSPROP_INIT_USEFMTONLYSSPROP_INIT_USEFMTONLY 控制連線到 SQL Server 2012 (11.x)SQL Server 2012 (11.x) 及更新版本時,如何擷取中繼資料。Controls how metadata is retrieved when connecting to SQL Server 2012 (11.x)SQL Server 2012 (11.x) and newer. 可能的值為 "true" 和 "false"。Possible values are "true" and "false". 預設值為 "false"。The default value is "false".

根據預設,SQL Server 的 OLE DB 驅動程式會使用sp_describe_first_result_setsp_describe_undeclared_parameters預存程式來取得中繼資料。By default, the OLE DB Driver for SQL Server uses sp_describe_first_result_set and sp_describe_undeclared_parameters stored procedures to retrieve metadata. 這些預存程式有一些限制(例如,在臨時表上操作時,它們會失敗)。These stored procedures have some limitations (e.g. they will fail when operating on temporary tables). 將 [使用 set fmtonly ] 設定為 "true",會指示驅動程式改為使用SET set fmtonly來進行中繼資料抓取。Setting Use FMTONLY to "true" instructs the driver to use SET FMTONLY for metadata retrieval instead.
使用者識別碼User ID DBPROP_AUTH_USERIDDBPROP_AUTH_USERID SQL ServerSQL Server 登入名稱。The SQL ServerSQL Server login name.
Workstation IDWorkstation ID SSPROP_INIT_WSIDSSPROP_INIT_WSID 工作站識別碼。The workstation identifier.

[1]:若要改善安全性,使用驗證/存取權杖初始化屬性或其對應的連接字串關鍵字時,會修改加密和憑證驗證行為。[1]: To improve security, encryption and certificate validation behavior is modified when using Authentication/Access Token initialization properties or their corresponding connection string keywords. 如需詳細資訊,請參閱加密和憑證驗證For details, see Encryption and certificate validation.

請注意:在此連接字串中,"Old Password" 屬性會設定 SSPROP_AUTH_OLD_PASSWORD,這是無法透過提供者字串屬性取得的目前密碼 (可能已過期)。Note In the connection string, the "Old Password" property sets SSPROP_AUTH_OLD_PASSWORD, which is the current (possibly expired) password that is not available via a provider string property.

另請參閱See also

利用 OLE DB Driver for SQL Server 建置Building Applications with OLE DB Driver for SQL Server