asp.net.ph

IDataRecord Interface

System.Data Namespace


Provides access to the column values within each row for a DataReader, and is implemented by .NET data providers that access relational databases.

IDataRecord Interface Members

Collapse   Properties

Visibility Name Value Type Accessibility
public FieldCount Int32 [ Get ]
public Item ( String name ) Object [ Get ]
public Item ( Int32 i ) Object [ Get ]

Collapse   Methods

Visibility Name Parameters Return Type
public GetBoolean ( Int32 i ) Boolean
public GetByte ( Int32 i ) Byte
public GetBytes ( Int32 i , Int64 fieldOffset , Byte buffer , Int32 bufferoffset , Int32 length ) Int64
public GetChar ( Int32 i ) Char
public GetChars ( Int32 i , Int64 fieldoffset , Char buffer , Int32 bufferoffset , Int32 length ) Int64
public GetData ( Int32 i ) IDataReader
public GetDataTypeName ( Int32 i ) String
public GetDateTime ( Int32 i ) DateTime
public GetDecimal ( Int32 i ) Decimal
public GetDouble ( Int32 i ) Double
public GetFieldType ( Int32 i ) Type
public GetFloat ( Int32 i ) Single
public GetGuid ( Int32 i ) Guid
public GetInt16 ( Int32 i ) Int16
public GetInt32 ( Int32 i ) Int32
public GetInt64 ( Int32 i ) Int64
public GetName ( Int32 i ) String
public GetOrdinal ( String name ) Int32
public GetString ( Int32 i ) String
public GetValue ( Int32 i ) Object
public GetValues ( Object values ) Int32
public IsDBNull ( Int32 i ) Boolean

Classes that Implement IDataRecord


Class Description
OleDbDataReader Provides a way of reading a forward-only stream of data rows from a data source.
SqlDataReader Provides a means of reading a forward-only stream of rows from an SQL Server™ database.

Remarks

The IDataReader and IDataRecord interfaces allow an inheriting class to implement a DataReader class, which provides a means of reading one or more forward-only streams of result sets. For more information about DataReader classes, see the ADO.NET DataReader. For more information about implementing .NET data providers, see Implementing a .NET Data Provider.

An application does not create an instance of the IDataRecord interface directly, but initializes an instance of a class that inherits IDataRecord. Typically this is done by obtaining a DataReader through ExecuteReader method of the Command object.

Classes that inherit IDataRecord must implement the inherited members, and typically define additional members to add provider-specific functionality.

Providers implementing a DataReader are required to expose data in common language runtime ( CLR ) types. Type coercion is defined for some types not included in the CLR. These values may be accessed as alternate types, which conform to CLR types. As an example, the following table lists suggested mappings from OLE DB data types to CLR types, and lists alternate types in parentheses in the CLR Type column.


OLE DB Type CLR Type
DBTYPE_BOOL Int16
DBTYPE_BSTR string
DBTYPE_BYTES byte [ ]
DBTYPE_CY Decimal
DBTYPE_DATE DateTime
DBTYPE_DBDATE DateTime
DBTYPE_DBTIME DateTime
DBTYPE_DBTIMESTAMP DateTime
DBTYPE_DECIMAL Decimal
DBTYPE_EMPTY null
DBTYPE_ERROR ExternalException
DBTYPE_FILETIME DateTime
DBTYPE_GUID Guid
DBTYPE_HCHAPTER not supported
DBTYPE_I1 SByte
DBTYPE_I2 Int16
DBTYPE_I4 Int32
DBTYPE_I8 Int64
DBTYPE_IDISPATCH object
DBTYPE_IUNKNOWN object
DBTYPE_NULL DBNull.Value
DBTYPE_NUMERIC Decimal
DBTYPE_PROPVARIANT object
DBTYPE_R4 Single
DBTYPE_R8 Double
DBTYPE_STR string
DBTYPE_UDT not supported
DBTYPE_UI1 byte ( Int16 )
DBTYPE_UI2 UInt16 ( Int32 )
DBTYPE_UI4 UInt32 ( Int64 )
DBTYPE_UI8 UInt64 ( Decimal )
DBTYPE_VARIANT object
DBTYPE_VARNUMERIC not supported
DBTYPE_WSTR string

Example

The following examples demonstrate using the IDataRecord interface to render the data items of a templated control that are bound to the column values within each row of a DataReader.

Binding a DataReader to a Repeater
Run Sample | View Source
Binding a DataReader to a DataList
Run Sample | View Source
Binding a DataReader to a DataGrid
Run Sample | View Source

See Also

IDataReader   OleDbDataReader   SqlDataReader Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph