OleDbConnection.Provider 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取在连接字符串的“Provider = ”子句中指定的 OLE DB 提供程序的名称。
public:
property System::String ^ Provider { System::String ^ get(); };
[System.ComponentModel.Browsable(true)]
public string Provider { get; }
[System.Data.DataSysDescription("OleDbConnection_Provider")]
public string Provider { get; }
[<System.ComponentModel.Browsable(true)>]
member this.Provider : string
[<System.Data.DataSysDescription("OleDbConnection_Provider")>]
member this.Provider : string
Public ReadOnly Property Provider As String
属性值
在连接字符串的“Provider= ”子句中指定的提供程序的名称。 默认值为一个空字符串。
- 属性
示例
以下示例创建 并 OleDbConnection 显示其一些只读属性。
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.
}
}
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