OracleConnection 构造函数

定义

初始化 OracleConnection 的新实例。Initializes a new instance of the OracleConnection.

重载

OracleConnection()

初始化 OracleConnection 的新实例。Initializes a new instance of the OracleConnection.

OracleConnection(String)

使用指定的连接字符串初始化 OracleConnection 类的新实例。Initializes a new instance of the OracleConnection class with the specified connection string.

OracleConnection()

初始化 OracleConnection 的新实例。Initializes a new instance of the OracleConnection.

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

示例

下面的示例创建并打开 OracleConnectionThe 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

OracleConnection(String)

使用指定的连接字符串初始化 OracleConnection 类的新实例。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)

参数

connectionString
String

用于打开数据库的连接。The connection used to open the database.

示例

下面的示例创建并打开 OracleConnectionThe 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

适用于