Listing Installed OLE DB Providers

[ Team LiB ] Recipe 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. | Team LiB Recipe 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 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 Namespaces variables and constants using System using using using using using . . . SQL Server extended stored procedure StringBuilder result new StringBuilder Using SQL Server xp_enum_oledb_providers. int count 0 SqlConnection conn new SqlConnection Sql_Master_ConnectString Create a command to execute the extended stored procedure to retrieve OLE DB providers. SqlCommand cmd new SqlCommand xp_enum_oledb_providers conn Create the DataReader. SqlDataReader rdr Iterate through the OLE DB providers in the DataReader. while count rdr Provider Description .ToString Registry Scan StringBuilder result new StringBuilder Using Registry scan. int count 0 Get the HKEY_CLASSES_ROOT CLSID key. RegistryKey keyCLSID CLSID false Iterate through the collection of subkeys. String keys for int i 0 i i Look for the OLE DB Provider subkey and retrieve the value if found. RegistryKey key keys i false RegistryKey subKey .

Bấm vào đây để xem trước nội dung
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.