OdbcConnection Constructors

Definition

Initializes a new instance of the OdbcConnection class.

Overloads

OdbcConnection()

Initializes a new instance of the OdbcConnection class.

OdbcConnection(String)

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

OdbcConnection()

Source:
OdbcConnection.cs
Source:
OdbcConnection.cs
Source:
OdbcConnection.cs
Source:
OdbcConnection.cs
Source:
OdbcConnection.cs

Initializes a new instance of the OdbcConnection class.

public:
 OdbcConnection();
public OdbcConnection ();
Public Sub New ()

Examples

The following example creates and opens an OdbcConnection.

static private void CreateOdbcConnection()
{
    using (OdbcConnection connection = new OdbcConnection())
    {
        connection.ConnectionString = "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\Samples\\Northwind.mdb";
        connection.Open();
    }
}
Private Sub CreateOdbcConnection()

    Using connection As New OdbcConnection
        connection.ConnectionString = "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\Samples\Northwind.mdb"
        connection.Open()
    End Using

End Sub

Remarks

When a new instance of OdbcConnection is created, the write-only and read-only properties are set to the following initial values unless they are specifically set using their associated keywords in the ConnectionString property.

Properties Initial value
ConnectionString empty string ("")
ConnectionTimeout 15
Database empty string ("")

You can change the value for these properties only by using the ConnectionString property.

See also

Applies to

OdbcConnection(String)

Source:
OdbcConnection.cs
Source:
OdbcConnection.cs
Source:
OdbcConnection.cs
Source:
OdbcConnection.cs
Source:
OdbcConnection.cs

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

public:
 OdbcConnection(System::String ^ connectionString);
public OdbcConnection (string? connectionString);
public OdbcConnection (string connectionString);
new System.Data.Odbc.OdbcConnection : string -> System.Data.Odbc.OdbcConnection
Public Sub New (connectionString As String)

Parameters

connectionString
String

The connection used to open the data source.

Examples

The following example creates and opens an OdbcConnection.

static private void CreateOdbcConnection()
{
    string connectionString = "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\Samples\\Northwind.mdb";

    using (OdbcConnection connection = new OdbcConnection(connectionString))
    {
        connection.Open();
    }
}
Private Sub CreateOdbcConnection()
    Dim connectionString As String = "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\Samples\Northwind.mdb"

    Using connection As New OdbcConnection(connectionString)
        connection.Open()
    End Using

End Sub

Remarks

When a new instance of OdbcConnection is created, the write-only and read-only properties are set to the following initial values unless they are specifically set using their associated keywords in the ConnectionString property.

Properties Initial value
ConnectionString connectionString
ConnectionTimeout 15
Database empty string ("")

You can change the value for these properties only by using the ConnectionString property.

See also

Applies to