Export (0) Print
Expand All

SqlDataSourceView.ExecuteSelect Method

Retrieves data from the underlying database using the SelectCommand SQL string and any parameters that are in the SelectParameters collection.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

protected internal override IEnumerable ExecuteSelect(
	DataSourceSelectArguments arguments
)

Parameters

arguments
Type: System.Web.UI.DataSourceSelectArguments

A DataSourceSelectArguments object used to request operations on the data beyond basic data retrieval.

Return Value

Type: System.Collections.IEnumerable
An IEnumerable list of data rows.

ExceptionCondition
NotSupportedException

The arguments passed to the ExecuteSelect method specify that the data source should perform some additional work while retrieving data to enable paging or sorting through the retrieved data, but the data source control does not support the requested capability.

- or -

Caching is enabled but the DataSourceMode property of the data source is not set to DataSet.

- or -

The SortParameterName property is set but CommandType is not set to StoredProcedure.

InvalidOperationException

The data source cannot create a database connection.

- or -

Caching is enabled but the internal cache and command types do not match.

The SqlDataSourceView class implements the inherited ExecuteSelect method to retrieve data from a database. Page developers and data-bound control authors do not call the ExecuteSelect method directly; instead, use the publicly exposed Select method.

Before the data retrieval is performed, the OnSelecting method is called to raise the Selecting event. You can handle this event to examine the values of the parameters and to perform any preprocessing before data is retrieved.

To perform the operation, the SqlDataSourceView object builds a DbCommand object using the SelectCommand text and any associated SelectParameters, and executes it against the underlying database. After the operation completes, the OnSelected method is called to raise the Selected event. You can handle this event to examine any return values, error codes, and perform any post-processing.

The ExecuteSelect method returns a DataView object if the DataSourceMode is set to DataSet, or a IDataReader object if the DataSourceMode is set to DataReader. Close the IDataReader object when you have finished reading the data.

If the DataSourceMode is set to DataSet and caching is enabled, the SqlDataSourceView retrieves data from and saves data to the cache during the data operation. The cache is created, discarded, or refreshed based on the caching behavior specified by the combination of the CacheDuration and CacheExpirationPolicy properties.

Security noteSecurity Note

When you are using client impersonation under Windows authentication, the data is cached when the first user accesses the data. If another user requests the same data, the data is retrieved from the cache. The data is not retrieved by making another call to the database to verify the user's access to the data. If you expect multiple users to access the data, and you want each retrieval to the data to be verified by the database's security configurations, do not use caching.

If the DataSourceMode is set to DataSet and a FilterExpression has been specified, it is evaluated along with any supplied FilterParameters and the resulting filter is applied to the list of data during the data retrieval operation.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft