DataTableReader.Read Method

Advances the DataTableReader to the next record.

Namespace: System.Data
Assembly: System.Data (in system.data.dll)

public override bool Read ()
public boolean Read ()
public override function Read () : boolean
Not applicable.

Return Value

true if there was another row to read; otherwise false.

Exception typeCondition

InvalidOperationException

An attempt was made to read or access a column in a closed DataTableReader .

The default position of the DataTableReader is before the first record. Therefore, you must call Read to start accessing any data.

The PrintColumns procedure loops through all the rows in the DataTableReader, displaying the contents of each column in the Console window.

private static void PrintColumns(DataTableReader reader)
{
    // Loop through all the rows in the DataTableReader
    while (reader.Read())
    {
        for (int i = 0; i < reader.FieldCount; i++)
        {
            Console.Write("{0} ", reader[i]);
        }
        Console.WriteLine();
    }
}

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

.NET Compact Framework

Supported in: 2.0

XNA Framework

Supported in: 1.0

Community Additions

ADD
Show: