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 public:
virtual IEnumerable^ ExecuteSelect (
	DataSourceSelectArguments^ arguments
) override
protected IEnumerable ExecuteSelect (
	DataSourceSelectArguments arguments
)
protected internal override function ExecuteSelect (
	arguments : DataSourceSelectArguments
) : IEnumerable
Not applicable.

Parameters

arguments

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

Return Value

An IEnumerable list of data rows.

Exception typeCondition

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.

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show: