locked
ADO.Net Transaction vs Database Transaction RRS feed

  • Question

  • I have a project to implement transactions. I have a doubt about where to implement transaction whether at database level or ado.net level. For ex, i am having a stored procedure to update a record. Do i have to implement transaction in stored procedure level or i have to implement transaction in ado.net. Please let me know which one is very efficient and why?
    Balaji
    • Moved by SamAgain Monday, June 21, 2010 9:14 AM better fit (From:Building Development and Diagnostic Tools for .Net)
    Monday, June 21, 2010 6:37 AM

Answers

  • If you need to update one record or need to execute single SQL statement, you do not need to open transaction at all, since single operations are always atomic. To open transaction from the code or in stored procedure will have same result. Everything depends on what you need to achieve from your code. If you need to call multiple stored procedures from your code inside of single transaction then you would open transaction from inside of your code, so you maintain and control it from central point. If the whole transaction "fits" into functionality of single stored procedure then you could use both ways


    Val Mazur (MVP) http://www.xporttools.net
    • Marked as answer by Alex Liang Sunday, June 27, 2010 1:36 PM
    Monday, June 21, 2010 10:18 AM