OleDbConnection OleDbConnection OleDbConnection OleDbConnection Constructors

정의

오버로드

OleDbConnection() OleDbConnection() OleDbConnection()

OleDbConnection 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the OleDbConnection class.

OleDbConnection(String) OleDbConnection(String) OleDbConnection(String) OleDbConnection(String)

지정된 연결 문자열을 사용하여 OleDbConnection 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the OleDbConnection class with the specified connection string.

OleDbConnection() OleDbConnection() OleDbConnection()

OleDbConnection 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the OleDbConnection class.

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

예제

다음 예제는 OleDbConnection합니다.The following example creates and opens an OleDbConnection.

static void OpenConnection(string connectionString)
{
    using (OleDbConnection connection = new OleDbConnection(connectionString))
    {
        try
        {
            connection.Open();
            Console.WriteLine("DataSource: {0} \nDatabase: {1}",
                connection.DataSource, connection.Database);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
        // The connection is automatically closed when the
        // code exits the using block.
    }
}
Public Sub OpenConnection(ByVal connectionString As String)

    Using connection As New OleDbConnection(connectionString)
        Try
            connection.Open()
            Console.WriteLine("DataSource: {0} Database: {1}", _
                connection.DataSource, connection.Database)
        Catch ex As Exception
            Console.WriteLine(ex.Message)
        End Try
        ' The connection is automatically closed when the
        ' code exits the Using block.
    End Using
End Sub

설명

새 인스턴스가 OleDbConnection 만들어지면 읽기/쓰기 속성의 관련된 키워드를 사용 하 여 구체적으로 설정 되어 있지 않으면 다음 초기 값으로 설정 됩니다는 ConnectionString 속성입니다.When a new instance of OleDbConnection is created, the read/write 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 1515
Database 빈 문자열 ("")empty string ("")
DataSource 빈 문자열 ("")empty string ("")

사용 하 여 이러한 속성에 대 한 값을 변경할 수는 ConnectionString 속성입니다.You can change the value for these properties only by using the ConnectionString property.

추가 정보

OleDbConnection(String) OleDbConnection(String) OleDbConnection(String) OleDbConnection(String)

지정된 연결 문자열을 사용하여 OleDbConnection 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the OleDbConnection class with the specified connection string.

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

매개 변수

connectionString
String String String String

데이터베이스를 여는 데 사용되는 연결입니다.The connection used to open the database.

예제

다음 예제는 OleDbConnection합니다.The following example creates and opens an OleDbConnection.

static void OpenConnection(string connectionString)
{
    using (OleDbConnection connection = new OleDbConnection(connectionString))
    {
        try
        {
            connection.Open();
            Console.WriteLine("DataSource: {0} \nDatabase: {1}",
                connection.DataSource, connection.Database);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
        // The connection is automatically closed when the
        // code exits the using block.
    }
}
Public Sub OpenConnection(ByVal connectionString As String)

    Using connection As New OleDbConnection(connectionString)
        Try
            connection.Open()
            Console.WriteLine("DataSource: {0} Database: {1}", _
                connection.DataSource, connection.Database)
        Catch ex As Exception
            Console.WriteLine(ex.Message)
        End Try
        ' The connection is automatically closed when the
        ' code exits the Using block.
    End Using
End Sub

설명

새 인스턴스가 OleDbConnection 만들어지면 읽기/쓰기 속성의 관련된 키워드를 사용 하 여 구체적으로 설정 되어 있지 않으면 다음 초기 값으로 설정 됩니다는 ConnectionString 속성입니다.When a new instance of OleDbConnection is created, the read/write 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 1515
Database 빈 문자열 ("")empty string ("")
DataSource 빈 문자열 ("")empty string ("")

사용 하 여 이러한 속성에 대 한 값을 변경할 수는 ConnectionString 속성입니다.You can change the value for these properties only by using the ConnectionString property.

추가 정보

적용 대상