In-depth analysis of DataReader: Continuous updates

Source: Internet
Author: User

// Perfume bad AT 06-07-25

// Depressing things always keep going. The invisible pressure comes from the fear.

When we use. net for data operations, we have a lot of contact with DataReader.


System. Data. OleDb. OleDbDataReader;
System. Data. Odbc. OdbcDataReader;
System. Data. SqlClient. SqlDataReader;

Inherit from
System. externalbyrefobject; // allow objects to be accessed across application domain boundaries in applications that support remote processing.
System. Collections. IEnumerable;
System. Data. IDataReader;
Inherit from
System. Data. IDataRecord;
System. IDisposable;
// IDataReader defines the value of a row of records, the common method of field names, and the attribute interface such as: object this [string name] {get ;}; object this [int I] {get ;}

The following describes in detail the attributes of this [string name] And this [int I] (we believe that this attribute is frequently called)
I think there are many attributes that you can see when using NameValueCollection. Otherwise, they are completely different concepts.
In fact, this [string name] is a convenient operation of this [int I ].
First, you can use the GetOrdinal method in this [string name] to obtain the index of the field name, and then call the GetValue method to obtain the value.
It can be seen that calling this [int I] is much more efficient than calling this [string name ]. *-*

The GetOrdinal method uses the GetName method to compare all column field names. If no index number is returned, an exception is thrown.

// You have time to make up for it today (the network was disconnected yesterday, and it was sent again today)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.