安裝 OLE DB Driver for SQL ServerInstalling 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 的 OLE DB 驅動程式, 您需要內含 msoledbsql.h 安裝程式。To install the OLE DB Driver for SQL Server you need msoledbsql.msi installer. 執行安裝程式, 並進行您偏好的選擇。Run the installer and make your preferred selections. SQL Server 的 OLE DB 驅動程式可以與舊版 Microsoft OLE DB 提供者並存安裝。The OLE DB Driver for SQL Server can be installed side-by-side with earlier versions of Microsoft OLE DB providers.

SQL Server 檔案的 OLE DB 驅動程式 (內含 msoledbsql.h, msoledbsqlr. semsfc.rll) 會安裝在中%SYSTEMROOT%\system32\The OLE DB Driver for SQL Server files (msoledbsql.dll, msoledbsqlr.rll) are installed in %SYSTEMROOT%\system32\ . 此外, x64 內含 msoledbsql.h 會在中%SYSTEMROOT%\SysWOW64\安裝32位的二進位檔。Additionally, the x64 msoledbsql.msi installs 32-bit binaries in %SYSTEMROOT%\SysWOW64\.

注意

所有適用于 SQL Server 的 OLE DB 驅動程式的登錄設定, 都是在安裝過程中進行。All appropriate registry settings for the OLE DB Driver for SQL Server are made as part of the installation process.

SQL Server 標頭和程式庫檔案 (內含 msoledbsql.h 和內含 msoledbsql.h) 的 OLE DB 驅動程式會安裝在中%PROGRAMFILES%\Microsoft SQL Server\Client SDK\OLEDB\182\SDKThe OLE DB Driver for SQL Server header and library files (msoledbsql.h and msoledbsql.lib) are installed in %PROGRAMFILES%\Microsoft SQL Server\Client SDK\OLEDB\182\SDK. 此外, x64 內含 msoledbsql.h 也會在中%PROGRAMFILES(x86)%\Microsoft SQL Server\Client SDK\OLEDB\182\SDK安裝相同的檔案。Additionally, the x64 msoledbsql.msi installs the same files in %PROGRAMFILES(x86)%\Microsoft SQL Server\Client SDK\OLEDB\182\SDK.

您可以透過內含 msoledbsql.h 散發 SQL Server 的 OLE DB 驅動程式。You can distribute OLE DB Driver for SQL Server through msoledbsql.msi. 當您部署應用程式時, 您可能必須安裝 SQL Server 的 OLE DB 驅動程式。You might have to install OLE DB Driver for SQL Server when you deploy an application. 使用 Chainer 和 Bootstrapper 技術是安裝多個封裝 (但對使用者卻好像是單一安裝) 的一種方法。One way to install multiple packages in what seems to the user to be a single installation is to use chainer and bootstrapper technology. 如需詳細資訊,請參閱撰寫適用於 Visual Studio 2005 的自訂啟動載入器套件新增自訂的必要條件For more information, see Authoring a Custom Bootstrapper Package for Visual Studio 2005 and Adding Custom Prerequisites.

X64 內含 msoledbsql.h 也會安裝32位版本的 OLE DB 驅動程式以進行 SQL Server。The x64 msoledbsql.msi also installs the 32-bit version of OLE DB Driver for SQL Server. 如果您的應用程式是以開發所在的平臺為目標, 您可以下載適用于 x64 和 x86 的內含 msoledbsql.h 版本。If your application targets a platform other than the one it was developed on, you can download versions of msoledbsql.msi for x64 and x86.

當您叫用 msoledbsql.msi 時,預設只會安裝用戶端元件。When you invoke msoledbsql.msi, only the client components are installed by default. 用戶端元件是支援應用程式執行的檔案,應用程式則是使用 OLE DB Driver for SQL Server 所開發。The client components are files that support running an application that was developed using OLE DB Driver for SQL Server. 如果也要安裝 SDK 元件,請在命令列上指定 ADDLOCAL=AllTo also install the SDK components, specify ADDLOCAL=All on the command line. 例如:For example:

msiexec /i msoledbsql.msi ADDLOCAL=ALL

自動安裝Silent install

如果您搭配 msiexec 使用 /passive、/qn、/qb 或 /qr 選項,則也必須指定 IACCEPTMSOLEDBSQLLICENSETERMS=YES,以明確指出您接受使用者授權條款。If you use the /passive, /qn, /qb, or /qr option with msiexec, you must also specify IACCEPTMSOLEDBSQLLICENSETERMS=YES, to explicitly indicate that you accept the terms of the end user license. 此選項必須以全部大寫的字母指定。This option must be specified in all capital letters.

將 SQL Server 的 OLE DB 驅動程式安裝為相依性Installing OLE DB Driver for SQL Server as a dependency

在卸載所有相依的應用程式之前, 請務必不要卸載 SQL Server 的 OLE DB 驅動程式。It is important not to uninstall OLE DB Driver for SQL Server until all dependent applications are uninstalled. 若要為使用者提供一則警告, 指出您的應用程式相依于 SQL Server 的 OLE DB 驅動程式, 請使用 MSI 中的 APPGUID 安裝選項, 如下所示:To provide users with a warning that your application depends on OLE DB Driver for SQL Server, use the APPGUID install option in your MSI, as follows:

msiexec /i msoledbsql.msi APPGUID={0CC618CE-F36A-415E-84B4-FB1BFF6967E1}

傳遞給 APPGUID 的值是您特定的產品代碼。The value passed to APPGUID is your specific product code. 使用 Microsoft Installer 來封裝應用程式安裝程式時,必須建立產品代碼。A product code must be created when using Microsoft Installer to bundle your application setup program. APPGUID 選項需要從提高許可權的命令提示字元執行安裝程式。The APPGUID option requires running the installer from an elevated Command Prompt.

另請參閱See Also

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