How can we perform transactions in .NET?Following are the general steps that are followed during a transaction:
1. Open connection. 2. Begin Transaction : The begin transaction method provides with a connection object this can be used to commit or rollback. 3. Execute the SQL commands. 4. Commit or roll back. 5. Close the database connection.How can we perform transactions in .NET?Steps to perform a transaction
1. Call the BeginTransaction. This marks the beginning of the transaction. 2. Assign the Transaction object returned by BeginTransaction to the Transaction property of the SqlCommand. 3. Execute the command. 4. Call the Commit method from SqlTransaction object to save the changes made to the data through the transaction. Call Rollback undo all the transaction which belong to this transaction.
|