共用方式為


OracleConnection 建構函式

定義

初始化 OracleConnection 的新執行個體。

多載

OracleConnection()

初始化 OracleConnection 的新執行個體。

OracleConnection(String)

使用指定的連接字串,初始化 OracleConnection 類別的新執行個體。

OracleConnection()

初始化 OracleConnection 的新執行個體。

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

範例

下列範例會建立並開啟 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

適用於

OracleConnection(String)

使用指定的連接字串,初始化 OracleConnection 類別的新執行個體。

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)

參數

connectionString
String

用來開啟資料庫的連接。

範例

下列範例會建立並開啟 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

適用於