SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Retrieves data from the underlying database using the SelectCommand SQL string and any parameters that are in the SelectParameters collection.
protected public:
override System::Collections::IEnumerable ^ ExecuteSelect(System::Web::UI::DataSourceSelectArguments ^ arguments);
protected internal override System.Collections.IEnumerable ExecuteSelect (System.Web.UI.DataSourceSelectArguments arguments);
override this.ExecuteSelect : System.Web.UI.DataSourceSelectArguments -> System.Collections.IEnumerable
Protected Friend Overrides Function ExecuteSelect (arguments As DataSourceSelectArguments) As IEnumerable
Parameters
- arguments
- DataSourceSelectArguments
A DataSourceSelectArguments object used to request operations on the data beyond basic data retrieval.
Returns
An IEnumerable list of data rows.
Exceptions
The arguments
passed to the ExecuteSelect(DataSourceSelectArguments) 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.
The data source cannot create a database connection.
-or-
Caching is enabled but the internal cache and command types do not match.
Remarks
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.
Important
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.