OleDbDataReader.Read 메서드

정의

다음 레코드로 진행합니다 OleDbDataReader .

public:
 override bool Read();
public:
 virtual bool Read();
public override bool Read();
public bool Read();
override this.Read : unit -> bool
abstract member Read : unit -> bool
override this.Read : unit -> bool
Public Overrides Function Read () As Boolean
Public Function Read () As Boolean

반품

true행이 더 있는 경우 그렇지 않으면 . false

구현

예제

다음 예제에서는 , OleDbConnection및 .를 OleDbCommandOleDbDataReader만듭니다. 이 예제에서는 데이터를 읽고 콘솔에 기록합니다. 마지막으로, 예제는 다음을 OleDbDataReaderOleDbConnection닫습니다.

private static void ReadData(string connectionString)
{
    string queryString = "SELECT OrderID, CustomerID FROM Orders";
    using (OracleConnection connection = new OracleConnection(connectionString))
    {
        OracleCommand command = new OracleCommand(queryString, connection);
        connection.Open();
        OracleDataReader reader;
        reader = command.ExecuteReader();

        // Always call Read before accessing data.
        while (reader.Read())
        {
            Console.WriteLine(reader.GetInt32(0) + ", " + reader.GetString(1));
        }

        // Always call Close when done reading.
        reader.Close();
    }
}
Public Sub ReadData(ByVal connectionString As String)
    Dim queryString As String = _
        "SELECT OrderID, CustomerID FROM Orders"

    Using connection As New OracleConnection(connectionString)
        Dim command As New OracleCommand(queryString, connection)
        connection.Open()

        Dim reader As OracleDataReader
        reader = command.ExecuteReader()

        ' Always call Read before accessing data.
        While reader.Read()
            Console.WriteLine(reader.GetInt32(0) & ", " & reader.GetString(1))
        End While

        ' Always call Close when done reading.
        reader.Close()
    End Using
End Sub

설명

기본 위치 OleDbDataReader 는 첫 번째 레코드 앞에 있습니다. 따라서 모든 데이터에 대한 액세스를 시작하려면 호출 Read 해야 합니다.

OleDbDataReader 사용 중인 동안 연결된 OleDbConnection 사용자가 호출Close할 때까지 해당 서비스를 사용 중입니다.

적용 대상

추가 정보