JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Using the SqlDataReader Class

The SqlDataReader class creates a data reader for use with the SQL Server. Here is the inheritance hierarchy of this class:

Object
   MarshalByRefObject
      SqlDataReader

You can find the more notable public properties of SqlDataReader objects in Table 22.26 and their more notable methods in Table 22.27. (This class has no non-inherited events.)

Table 22.26: Noteworthy public properties of SqlDataReader objects.

Property

Means

Depth

Gets the current row's nesting depth.

FieldCount

Gets the number of columns in the current row.

IsClosed

Indicates if a data reader is closed.

Item

Gets the value in a field.

RecordsAffected

Gets the number of rows changed, inserted, or deleted by an SQL statement.

Table 22.27: Noteworthy public methods of SqlDataReader objects.

Method

Means

Close

Closes the data reader.

GetBoolean

Gets a field's value as a Boolean.

GetByte

Gets a field's value as a byte.

GetBytes

Reads a stream of bytes.

GetChar

Gets a field's value as a single character.

GetChars

Reads a stream of characters.

GetData

Not currently supported.

GetDataTypeName

Gets the name of the source data type.

GetDateTime

Gets a field's value as a DateTime object.

GetDecimal

Gets a field's value as a Decimal object.

GetDouble

Gets a field's value as a double-precision floating point number.

GetFieldType

Gets the Type that is the data type of the object.

GetFloat

Gets a field's value as a single-precision floating point number.

GetGuid

Gets a field's value as a globally unique identifier (GUID).

GetInt16

Gets a field's value as a 16-bit signed integer.

GetInt32

Gets a field's value as a 32-bit signed integer.

GetInt64

Gets a field's value as a 64-bit signed integer.

GetName

Gets the name of the specified column.

GetOrdinal

Gets the column ordinal, given the name of the column.

GetSchemaTable

Returns a schema.

GetSqlBinary

Gets a field's value as a SqlBinary.

GetSqlByte

Gets a field's value as a SqlByte.

GetSqlDateTime

Gets a field's value as a SqlDateTime.

GetSqlDecimal

Gets a field's value as a SqlDecimal.

GetSqlDouble

Gets a field's value as a SqlDouble.

GetSqlGuid

Gets a field's value as a SqlGuid.

GetSqlInt16

Gets a field's value as a SqlInt16.

GetSqlInt32

Gets a field's value as a SqlInt32.

GetSqlInt64

Gets a field's value as a SqlInt64.

GetSqlMoney

Gets a field's value as a SqlMoney.

GetSqlSingle

Gets a field's value as a SqlSingle.

GetSqlString

Gets a field's value as a SqlString.

GetSqlValue

Gets an object of SqlDbType variant.

GetSqlValues

Gets all the attribute columns in the current row.

GetString

Gets a field's value as a string.

GetValue

Gets a field's value in its native format.

GetValues

Gets all attribute columns in the collection for the current row.

IsDBNull

Indicates if a column contains nonexistent (or missing) values.

Read

Advances a data reader to the next record and reads that record.

Previous Section Next Section




JavaScript Editor Free JavaScript Editor     JavaScript Editor