How to Write Atomic Transactions in .NET
page 2 of 7
by Keyvan Nayyeri
Feedback
Average Rating: 
Views (Total / Last 10 Days): 37424/ 51

Prepare Database

To write my sample, I created a simple table with three columns:

·         id (int)

·         Name (navarchar)

·         Value (int)

Consider each row is an account in a bank.  Next, I created a stored procedure to add a value to a specific account.

Listing 1

CREATE PROCEDURE dbo.AddToAccount
    (
    @id int,
    @value int
    )
AS
    UPDATE dbo.MyTable
    SET Value = (Value + @value)
    WHERE id= @id

To finish preparing my database, I added a sample account to my table.

Figure 1


View Entire Article

User Comments

Title: ASAS   
Name: ASAS
Date: 2012-08-01 7:53:47 AM
Comment:
asd
Title: Very Gud   
Name: Soby
Date: 2007-06-09 7:26:03 AM
Comment:
This is very Help for me

Product Spotlight
Product Spotlight 





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


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-18 10:08:53 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search