Click here to Skip to main content
15,900,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Is it better to have transactions in back end stored procedures or front end in c#?

Thanks
Posted
Updated 25-Oct-11 22:30pm
v2

Transactions are on servers only, but you can start them anywhere.

On the clients you might get connection timeouts which will automatically rollback the transaction.
 
Share this answer
 
If you're talking ADO, you can start a transaction with SqlConnection.BeginTransaction or something like that, I presume that's what you mean. I'd argue because you want to keep transactions as small and fast as possible its better to do them in the database. These also leads to a better encapsulation in that your database 'black-box' is transactionally sound.
 
Share this answer
 
Google is your friend!
There is a nice article on Transactions right here on CP Using Transactions in ADO.NET[^]
MSDN also has sufficient sources on Transactions[^]
You might also be interested in Distributed Transactions[^] and TransactionScope[^]
Use Transactions in SP's or ADO.NET?[^] I think the most important thing is that a Transaction actually does what it does, which is making sure actions are rolled back if an exception occurs!
If you want to use it in an SP or in code kind of depends on you and your situation.
Hope this helps :)
 
Share this answer
 
Comments
Espen Harlinn 26-Oct-11 5:20am    
5'ed (again)
Sander Rossel 26-Oct-11 13:38pm    
Thanks (again) :laugh:
What you are asking is not clear. What is the connection between transactions and SPs?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900