Possible Duplicate:
Transactions in .net
I just wanted to know about Transaction in .net using c# language. I have gone through different articles on the net. However, I came to know about transaction theoretically but I wanted to know the exact use of it in real time. For example when exactly should I use transactions in real time. Let’s suppose, I am writing code where I am doing some action on the click event of a link. Lets say, I am hitting the SQL connection to get some values. Should I use transaction there? If I am writing simple code, where I fetch values without using sql connection, should I use transactions there? What are the pros and cons of using Transactions. Getting theoritical knowledge is different, but I want to know the exact use of it. When to use when not to use. Can transactions be used in simple code? Any responses or links for even basic stuff about transactions are welcome.
No, there are not need to use transactions, when you are not alter data in database.
As you said, you have learned various articles, So may be you have figure out the reason of using the transactions. Look all of these in concern of database.
The advantages of three-tier applications in creating scalable and robust applications are made feasible by transaction processing systems. The ability to distribute the components that make up applications amongst separate servers without explicitly having to develop for that architecture is another advantage of transaction server processing. Transaction processing systems also ensure that transactions are atomic, consistent, isolated, and durable. This alleviates the developer from having to support these characteristics explicitly.
Why Do We Need Transaction Processing?
The Advantages Of Transaction Processing
Yes, you can simply write code in C# using ADO.Net. (e.g. SQLTransaction class)
e.g.
Reference:
Performing a Transaction Using ADO.NET
.NET 2.0 transaction model