Sqldatareader class, which is essential for ADO. net

Source: Internet
Author: User

SqldatareaderClass

Provides a method to read rows from the SQL Server database only into the stream. This class cannot be inherited.

 

Namespace: system. Data. sqlclient

Syntax:

Public class sqldatareader: dbdatareader,

Idatareader, idisposable, idatarecord

Note:

To create a sqldatareader, you must call the executereader method of the sqlcommand object instead of using the constructor directly.

Sqldatareader. hasrowsAttribute

Gets a value that indicates whether sqldatareader contains one or more rows.

Syntax:

Public override bool hasrows {Get ;}

Attribute Value

Type: system...:. Boolean

True if sqldatareader contains one or more rows; otherwise, false.

 

Sqldatareader. ReadMethod

Advances sqldatareader to the next record.

Syntax:

Public override bool read ()

Return Value:

Type: system...:. Boolean

True if multiple rows exist; otherwise, false.

Note:

The default position of sqldatareader is before the first record. Therefore, you must call read to access any data.

 

For each associated sqlconnection, only one sqldatareader can be opened at a time. Before the first connection is closed, any attempt to open the other will fail. Similarly, when sqldatareader is used, the associated sqlconnection is busy providing services for it until close is called.

 

Sqlcommand. executereaderMethod

Send commandtext to connection and generate a sqldatareader.

Syntax:

C #

Public sqldatareader executereader ()

Return Value:

Type: system. Data. sqlclient. sqldatareader

Returns a sqldatareader object.

 

ConnectionstateEnumeration

Describes the current status of the connection to the data source.

This enumeration has a flagsattribute attribute, which enables its member values to be combined by bit.

Syntax:

[Flagsattribute]

Public Enum connectionstate

Member:

The closed connection is closed.

The open connection is open.

The connecting connection object is connecting to the data source. (This value is reserved for future versions of this product .)

Executing connection object is executing command. (This value is reserved for future versions of this product .)

The fetching connection object is retrieving data. (This value is reserved for future versions of this product .)

The connection between the broken and the data source is interrupted. This can only happen after the connection is opened. You can close the connection in this status and then open it again. (This value is reserved for future versions of this product .)

Note:

The connectionstate value is used for the state attribute of oledbconnection and sqlconnection objects.

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.