Επεξεργασία

Κοινή χρήση μέσω


OracleConnection Constructors

Definition

Initializes a new instance of the OracleConnection.

Overloads

OracleConnection()

Initializes a new instance of the OracleConnection.

OracleConnection(String)

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

OracleConnection()

Initializes a new instance of the OracleConnection.

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

Examples

The following example creates and opens an OracleConnection.

public void CreateOracleConnection()
{
    string connectionString = "Data Source=Oracle8i;Integrated Security=yes";
    using (OracleConnection connection = new OracleConnection(connectionString))
    {
        connection.Open();
        Console.WriteLine("ServerVersion: " + connection.ServerVersion
            + "\nDataSource: " + connection.DataSource);
    }
}
Public Sub CreateOracleConnection()
    Dim connectionString As String = _
       "Data Source=Oracle8i;Integrated Security=yes"

    Using connection As New OracleConnection(connectionString)
        connection.Open()
        Console.WriteLine("ServerVersion: " + connection.ServerVersion _
           + ControlChars.NewLine + "DataSource: " + connection.DataSource)
    End Using
End Sub

Applies to

OracleConnection(String)

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

public:
 OracleConnection(System::String ^ connectionString);
public OracleConnection (string connectionString);
new System.Data.OracleClient.OracleConnection : string -> System.Data.OracleClient.OracleConnection
Public Sub New (connectionString As String)

Parameters

connectionString
String

The connection used to open the database.

Examples

The following example creates and opens an OracleConnection.

public void CreateOracleConnection()
{
    string connectionString = "Data Source=Oracle8i;Integrated Security=yes";
    using (OracleConnection connection = new OracleConnection(connectionString))
    {
        connection.Open();
        Console.WriteLine("ServerVersion: " + connection.ServerVersion
            + "\nDataSource: " + connection.DataSource);
    }
}
Public Sub CreateOracleConnection()
    Dim connectionString As String = _
       "Data Source=Oracle8i;Integrated Security=yes"

    Using connection As New OracleConnection(connectionString)
        connection.Open()
        Console.WriteLine("ServerVersion: " + connection.ServerVersion _
           + ControlChars.NewLine + "DataSource: " + connection.DataSource)
    End Using
End Sub

Applies to