DB2 10.5 for Linux, UNIX, and Windows

DB2Connection Constructor

Initializes a new instance of the DB2Connection class.

Overload list

Name Description
New()

Initializes a new instance of the DB2®Connection class.

New(String)

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

Example

[Visual Basic, C#] The following example creates and opens a DB2Connection.

Note: [Visual Basic, C#] This example shows how to use one of the overloaded versions of the DB2Connection constructor. For other examples that might be available, see the individual overload topics.
[Visual Basic]
Public Sub CreateDB2Connection()
    Dim myConnString As String = "DATABASE=SAMPLE;"
    Dim myConnection As New DB2Connection(myConnString)
    myConnection.Open()
End Sub

[C#]
public void CreateDB2Connection()
{
   string myConnString = "DATABASE=SAMPLE;";
   DB2Connection myConnection = new DB2Connection(myConnString);
   myConnection.Open();
}