OleDbConnection.Provider 属性
获取在连接字符串的“Provider = ”子句中指定的 OLE DB 提供程序的名称。
**命名空间:**System.Data.OleDb
**程序集:**System.Data(在 system.data.dll 中)
语法
声明
Public ReadOnly Property Provider As String
用法
Dim instance As OleDbConnection
Dim value As String
value = instance.Provider
public string Provider { get; }
public:
property String^ Provider {
String^ get ();
}
/** @property */
public String get_Provider ()
public function get Provider () : String
属性值
在连接字符串的“Provider= ”子句中指定的提供程序的名称。默认值为空字符串。
示例
下面的示例创建一个 OleDbConnection 并显示它的一些只读属性。
Public Sub OpenConnection(ByVal connectionString As String)
Using connection As New OleDbConnection(connectionString)
Try
connection.Open()
Console.WriteLine("ServerVersion: {0} Provider: {1}", _
connection.ServerVersion, connection.Provider)
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
' The connection is automatically closed when the
' code exits the Using block.
End Using
End Sub
static void OpenConnection(string connectionString)
{
using (OleDbConnection connection = new OleDbConnection(connectionString))
{
try
{
connection.Open();
Console.WriteLine("ServerVersion: {0} \nProvider: {1}",
connection.ServerVersion, connection.Provider);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
// The connection is automatically closed when the
// code exits the using block.
}
using System;
using System.Data;
using System.Data.OleDb;
class Class1
{
static void Main()
{
string x = "Provider=SQLOLEDB;Data Source=(local);Initial Catalog=AdventureWorks;"
+ "Integrated Security=SSPI";
OpenConnection(x);
Console.ReadLine();
}
static void OpenConnection(string connectionString)
{
using (OleDbConnection connection = new OleDbConnection(connectionString))
{
try
{
connection.Open();
Console.WriteLine("ServerVersion: {0} \nProvider: {1}",
connection.ServerVersion, connection.Provider);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
// The connection is automatically closed when the
// code exits the using block.
}
平台
Windows 98、Windows 2000 SP4、Windows Millennium Edition、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition
.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。
版本信息
.NET Framework
受以下版本支持:2.0、1.1、1.0
请参见
参考
OleDbConnection 类
OleDbConnection 成员
System.Data.OleDb 命名空间