ExecuteReader Method (CommandBehavior)

MySQL Connector/Net

Sends the CommandText to the Connection, and builds a MySqlDataReader using one of the CommandBehavior values.

Namespace:  MySql.Data.MySqlClient
Assembly:  MySql.Data (in MySql.Data.dll) Version: 6.2.2.0

Syntax

C#
public MySqlDataReader ExecuteReader(
	CommandBehavior behavior
)
Visual Basic (Declaration)
Public Function ExecuteReader ( _
	behavior As CommandBehavior _
) As MySqlDataReader
Visual C++
public:
MySqlDataReader^ ExecuteReader(
	CommandBehavior behavior
)

Parameters

behavior
Type: System.Data..::.CommandBehavior
One of the CommandBehavior values.

Return Value

A MySqlDataReader object.

Remarks

When the CommandType property is set to StoredProcedure, the CommandText property should be set to the name of the stored procedure. The command executes this stored procedure when you call ExecuteReader.

The MySqlDataReader supports a special mode that enables large binary values to be read efficiently. For more information, see the SequentialAccess setting for CommandBehavior.

While the MySqlDataReader is in use, the associated MySqlConnection is busy serving the MySqlDataReader. While in this state, no other operations can be performed on the MySqlConnection other than closing it. This is the case until the Close()()() method of the MySqlDataReader is called. If the MySqlDataReader is created with CommandBehavior set to CloseConnection, closing the MySqlDataReader closes the connection automatically.

Note: When calling ExecuteReader with the SingleRow behavior, you should be aware that using a limit clause in your SQL will cause all rows (up to the limit given) to be retrieved by the client. The Read()()() method will still return false after the first row but pulling all rows of data into the client will have a performance impact. If the limit clause is not necessary, it should be avoided.

See Also