This documentation is archived and is not being maintained.

OleDbConnection Constructor

.NET Framework 1.1

Initializes a new instance of the OleDbConnection class.

Overload List

Initializes a new instance of the OleDbConnection class.

[Visual Basic] Public Sub New()
[C#] public OleDbConnection();
[C++] public: OleDbConnection();
[JScript] public function OleDbConnection();

Initializes a new instance of the OleDbConnection class with the specified connection string.

[Visual Basic] Public Sub New(String)
[C#] public OleDbConnection(string);
[C++] public: OleDbConnection(String*);
[JScript] public function OleDbConnection(String);

Example

[Visual Basic, C#, C++] The following example creates and opens an OleDbConnection.

[Visual Basic, C#, C++] Note   This example shows how to use one of the overloaded versions of the OleDbConnection constructor. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Public Sub CreateOleDbConnection()
    Dim myConnString As String = "Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=Northwind;Integrated Security=SSPI;Connect Timeout=30"
    Dim myConnection As New OleDbConnection(myConnString)
    myConnection.Open()
End Sub

[C#] 
public void CreateOleDbConnection() 
{
   string myConnString = "Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=Northwind;Integrated Security=SSPI;Connect Timeout=30";
   OleDbConnection myConnection = new OleDbConnection(myConnString);
   myConnection.Open();
}

[C++] 
public:
 void CreateOleDbConnection() 
 {
    String* myConnString = S"Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=Northwind;Integrated Security=SSPI;Connect Timeout=30";
    OleDbConnection* myConnection = new OleDbConnection(myConnString);
    myConnection->Open();
 }

[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.

See Also

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

Show: