Thư viện tri thức trực tuyến
Kho tài liệu với 50,000+ tài liệu học thuật
© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Tài liệu Listing Installed OLE DB Providers pptx
Nội dung xem thử
Mô tả chi tiết
[ Team LiB ]
Recipe 10.13 Listing Installed OLE DB Providers
Problem
You need a list of the OLE DB providers installed on the machine running your code.
Solution
Use a SQL Server extended stored procedure or search the registry.
In the first case, the sample code executes the extended stored procedure
xp_enum_oledb_providers. The result set containing the installed OLE DB providers is
displayed.
In the second case, the sample code uses the Microsoft.Win32.Registry class to examine
the registry, identify OLE DB provider subkeys, and retrieve and display the OLE DB
provider names from these subkeys.
The C# code is shown in Example 10-13.
Example 10-13. File: OleDbProvidersForm.cs
// Namespaces, variables, and constants
using System;
using System.Configuration;
using System.Text;
using Microsoft.Win32;
using System.Data;
using System.Data.SqlClient;
// . . .
// SQL Server extended stored procedure
StringBuilder result =
new StringBuilder("Using SQL Server xp_enum_oledb_providers." +
Environment.NewLine);
int count = 0;
SqlConnection conn = new SqlConnection(
ConfigurationSettings.AppSettings["Sql_Master_ConnectString"]);