Export (0) Print
Expand All

OleDbConnection.Provider Property

Gets the name of the OLE DB provider specified in the "Provider= " clause of the connection string.

[Visual Basic]
Public ReadOnly Property Provider As String
[C#]
public string Provider {get;}
[C++]
public: __property String* get_Provider();
[JScript]
public function get Provider() : String;

Property Value

The name of the provider as specified in the "Provider= " clause of the connection string. The default value is an empty string.

Example

[Visual Basic, C#, C++] The following example creates an OleDbConnection and displays some of its read-only properties.

[Visual Basic] 
Public Sub CreateOleDbConnection()
    Dim myConnString As String = _
       "Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=Northwind;Integrated Security=SSPI;"
    Dim myConnection As New OleDbConnection(myConnString)
    myConnection.Open()
    MessageBox.Show("ServerVersion: " + myConnection.ServerVersion _
       + ControlChars.NewLine + "Provider: " + myConnection.Provider)
    myConnection.Close()
End Sub

[C#] 
public void CreateOleDbConnection() 
{
   string myConnString = "Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=Northwind;Integrated Security=SSPI;";
   OleDbConnection myConnection = new OleDbConnection(myConnString);
   myConnection.Open();
   MessageBox.Show("ServerVersion: " + myConnection.ServerVersion
      + "\nProvider: " + myConnection.Provider);
   myConnection.Close();
}

[C++] 
public:
 void CreateOleDbConnection() 
 {
    String* myConnString = S"Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=Northwind;Integrated Security=SSPI;";
    OleDbConnection* myConnection = new OleDbConnection(myConnString);
    myConnection->Open();
    MessageBox::Show(String::Format( S"ServerVersion: {0}\nProvider: {1}", myConnection->ServerVersion, myConnection->Provider ));
    myConnection->Close();
 }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

OleDbConnection Class | OleDbConnection Members | System.Data.OleDb Namespace

Show:
© 2015 Microsoft