This prevents non-repetitive data reading (nonrepeatable reads );
Serialisable: locks the range in dataset to prevent other users from updating data or inserting rows in the database before the transaction processing ends;
Isolationlevel defines the lock record level, but this concept is not covered in this article. The object sqltransaction also provides a similar method. You can use the following methods to process transactions:
Commit: submits database transactions;
Rollback: never final state (pending state) Roll Back transaction processing. Once a transaction is committed, this operation cannot be performed;
Save: You can create a savepoint in a transaction to reverse a part of the transaction and specify the savepoint name.
The following C # example combines these parts.
This simple ConsoleProgramFollow these steps to insert two rows into the table of the northwind database:
Call the begintransaction method of the connection object to mark the start position of transaction processing. The begintransaction method returns a coordinate (Reference) for the transaction processing, which is specified to the command object used by the transaction processing.
Specify the transaction object to the transaction attribute of the command to be executed. If a command is executed on the connection in the active transaction and the transaction object is not specified to the transaction attribute of the command, an exception is thrown.
Call the commit method of the transaction object to end transaction processing, or call the rollback method to cancel transaction processing.
Equivalent VB. NETCodeSimilar.
Transaction Processing ends
Although this is a simple example, it fully shows how simple it is to use transactions in. NET applications. Remember that transaction processing is only necessary to process a group of commands.