Understanding Transaction in ADO.NET
page 1 of 8
Published: 22 Jun 2007
Abstract
In this article Sanjit describes how to use transactions in ADO.NET using C#, as well as within a stored procedure.
by SANJIT SIL
Feedback
Average Rating: 
Views (Total / Last 10 Days): 45415/ 57

Introduction

A transaction is a set of operations that must either succeed or fail as a unit. The goal of a transaction is to ensure that data is always in a valid, consistent state. For example, consider a transaction that transfers $1000 from account A to account B; clearly there are two transactions. 1) It should deduct $1000 from account A and 2) it should add $1000 to account B. Suppose that a transaction completes step 1, but fails in step 2 because of some errors. This leads to inconsistent data because the total amount of money is no longer accurate. A full $1000 has gone missing. Transactions help avoid these types of problems by ensuring that changes are committed to a database only if all the steps are successful. So in this example, if step 2 fails, then the changes made by step 1 will not be committed to the database. This ensures that the system stays in any of two valid states --- the initial state (with no money transferred) and the final state (with money debited from the account and credited to another). The sample code snippets have been written in C#.


View Entire Article

User Comments

No comments posted yet.






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-24 11:31:43 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search