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.