ASP. NET first knowledge 5

Source: Internet
Author: User

1. Connection Pool Technology
By default, the connection pool is enabled in ADO. Net to prevent the server from allocating resources for connection multiple times. Program Scalability and scalability
Connection lifetime: 0 indicates the maximum connection timeout for the connection pool.
Connection Reset: determines whether to reset the database connection when the database connection is extracted from the pool.
Endlist: the pool program automatically registers the connection in the context of the creation thread.
Load Balance Timeout: the shortest time for survival in the connection pool before the connection is destroyed (in seconds)
Max pool size: Maximum number of connections allowed in the pool
Min pool size: the minimum number of connections allowed in the pool
Pooling: When the value is true, the system extracts the sqlconnection object from the appropriate pool, or creates and adds the object to the appropriate pool as needed.
2. How to clear the connection pool
Clearallpools: Clear all SQL Server-related connection pools directly
Clearpool: clear specific connections
3. Optional commandbehavior values
Singleresult: the query returns a result set.
Schemaonly: Query returns only column information
Keyinfo: query the returned column and primary key information.
Singlerow: When performing a query that returns multiple result sets, one row is returned for the query, but each result set has only one row.
Sequentialaccess: When datareader processes rows containing columns with large binary values, sequentialaccess does not load the entire row, but enables datareader to load data as a stream, then, you can use the getbytes or getchars method to guide the location of the read operation and the limited buffer size of the data being returned.
Closeconnection: When executing this command, if the datareader object is closed, the associated connection object is also closed.
4. parameterdirection type enumeration Value
Input: the parameter is an input parameter, default value
Output: the parameter is an output parameter.
InputOutput: both input and output parameters
Returnvalue: the return value of an operation such as a stored procedure, built-in function, or user-defined function.
5. Use stored procedures
Commandtype should be set to commandtype. storedprocedure
6. Transactions
Reference System. Transactions namespace
Before initializing sqlconnection, declare a sqltransaction class to process database transactions.
After the connection is opened, use the sqlconnection method to start a transaction, return a transaction object, and then assign the transaction object to the sqlcommand object.
The sqlcommand object now processes a transaction environment and waits for the sqltransaction object to call the commit method to commit to the database or roll back the database.
7. The begintransaction method has multiple overload methods.
The enumerated attribute isolationlevel of the sqltransaction object. The enumerated values are as follows:
Unspecified is using a different isolation level than the specified isolation level, but cannot determine this level
The Chos cannot overwrite the pending changes in a transaction with a higher isolation level.
Readuncommitted can be used for dirty read, that is, no share lock is published or exclusive lock is accepted.
Readcommitted maintains a shared lock when reading data to avoid dirty reading, but data can be changed before the transaction ends, resulting in non-repeated reading or phantom data.
Repeatableread places a lock on all data used in the query to prevent other users from updating the data. Prevents repeated reads, but there can still be phantom rows
Serializable places a range lock on the dataset to prevent other users from updating rows or inserting rows into the dataset before the transaction is completed.
Snapshot reduces blocking by storing the same data version that another application can read when one application is modifying data.
Change isolation level: Transaction = conn. begintransaction (isolationlevel. readcommitted)
8. dataadapter and Dataset
The fillschema of the dataadapter object can fill the schema information of the dataset without filling in the Data SDA. fillschema (DS, schematype. mapped)
9. attributes of the datacolumn object
Allowdbnull: whether to allow null Columns
Autoincrement: whether to allow auto-increment of Columns
Autoincrementseed: Specifies the seed for increasing column characters
10. Use a DataSet object
You need to navigate between multiple tables
Use data from multiple sources
Need to be located back and forth in the table
Data exchange with remote machines
Cache, sort, search or filter data
11. Use datareader
You only need to display the changed data, such as the help information of some systems, such as the organization, department, and company information, and do not need to be modified frequently.
Data does not need to be cached. New data must be retrieved from the database for each refresh.
Data needs to be accessed in read-only and forward mode
The result set is too large to occupy too much memory.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.