Sends the SqlCommand.CommandText to the SqlCommand.Connection, and builds a System.Data.SqlClient.SqlDataReader using one of the System.Data.CommandBehavior values.
- behavior
- One of the System.Data.CommandBehavior values.
A System.Data.SqlClient.SqlDataReader object.
When the SqlCommand.CommandType property is set to StoredProcedure, the SqlCommand.CommandText property should be set to the name of the stored procedure. The command executes this stored procedure when you call SqlCommand.ExecuteReader.
Use System.Data.CommandBehavior.SequentialAccess to retrieve large values and binary data. Otherwise, an OutOfMemoryException might occur and the connection will be closed.
The multiple active result set (MARS) feature allows for multiple actions using the same connection.
If you use SqlCommand.ExecuteReader or SqlCommand.BeginExecuteReader to access XML data, SQL Server will return any XML results greater than 2,033 characters in length in multiple rows of 2,033 characters each. To avoid this behavior, use SqlCommand.ExecuteXmlReader or erload:System.Data.SqlClient.SqlCommand.BeginExecuteXmlReader to read FOR XML queries. For more information, see article Q310378, "PRB: XML Data Is Truncated When You Use SqlDataReader," in the Microsoft Knowledge Base at http://support.microsoft.com.