The sqldatasource control consists of four precision spaces:
1. Wizard. 2. attributes. 3. Control PropertiesCode. 4. Background code.
1. Wizard: Click Next> next> finish.
Database connection string> Custom SQL statement or stored procedure> specify the parameter source of the where statement.
Database connection string-> select table-> Select column-> Configure where statement, Orde rby statement, generate insert, update, delete statement-> specify the parameter source of where statement. (This is a graphical Operation)
The control Property Code is generated for each step of the wizard.
2. attribute: A list of attributes that you configure.
The wizard can implement attributes, and more can be implemented. Including cache, whether the obtained value is null or not, data conflict, datareader or dataset, and view status.
Property operation, and the control Property Code is generated at the same time.
3. Control Property Code: HTML hasSource codeThe Asp.net control also has source code.
4. Background code: the control property code can be implemented, and the background code can be implemented more. For example, you can use the sqldatasource control to display binary data images without data binding controls. Background code often uses the sqldatasource control event to handle various problems. For example, if the SQL query statement parameter is not declared in the control property code, you can add an SQL query statement parameter in the background code.
-----------------------------------------------------------------
Programming> Asp. Net 3.5 development example analysis> sqldatasource control> wizard> specify parameters
All query, deletion, insertion, and update of SQL statements require parameters for locating. Parameter Source:
The Asp.net control allows you to set custom parameters for the web. config file, query string, session, cookie, and background code.
-----------------------------------------------------------------
Programming> Asp. Net 3.5 development example analysis> sqldatasource control> attribute> cancelselectonnullparameter attribute
Drop-down list. No data is selected, but all data is retrieved.
The SQL query statement requires a parameter. If you give it a null string, the sqldatasource control gets the parameter null, and sqldatasource does not execute the query statement.
Set the cancelselectonnullparameter attribute to false and then rewrite the SQL statement.
-----------------------------------------------------------------
Programming> Asp. Net 3.5 development example analysis> sqldatasource control> attribute> performancemode attribute
The datasourcemode attribute has two options: datareader and dataset. Datareader is fast and does not support caching, paging, and dynamic sorting. Dataset supports caching, paging, and dynamic sorting, but the speed is slow. Essentially, the data obtained by datareader is not stored in the server memory, but dataset will.
-----------------------------------------------------------------
Programming> Asp. Net 3.5 development example analysis> sqldatasource control> Properties> Use fileterexpression to filter data
There are two ways to read the required data. 1. Set where = directly in the SQL query statement. 2. All SQL query statements are found and filtered using the fileterexpression attribute. Therefore, the second method requires dataset, cache, and parameters.
The second method has the following advantages: frequent filtering of other conditions and high speed. However, if other conditions are not filtered, the speed is obviously wasted.
-----------------------------------------------------------------
Programming> Asp. Net 3.5 development example analysis> sqldatasource control> background code> SQL command execution error handling
People are floating in the rivers and lakes.ProgramIs no exception. How to capture sqldatasource control exceptions (for example, querying a non-existent table in an SQL statement), you only need to insert, update, or delete a statement in the selected (or insert, update, or delete) of the sqldatasource control) write the exception judgment and capture code in the event processing function. I also want to tell the compiler that the exception has been handled by myself, that is, the exceptionhandled attribute is set to true.
-----------------------------------------------------------------
Programming> Asp. Net 3.5 development example analysis> exploring sqldatasource control> background code> canceling sqldatasource control execution
Before sqldatasource is executed, if the parameter meets the requirements, the execution is canceled.
In the background code, write code in the event to determine whether the parameter is correct or not. There are five types of events: Query, add, delete, modify, and filter)