Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello friends,

Now I know that we can enclose a bunch of SQL queries (CommandText of Command object) in a transaction context. That way, if any of the queries fail, the entire transaction is rolled back. The command object allows us to do that. Now, my problem is that I have a bunch of methods, each one of which in turn fires a stored procedure to achieve the above functionality (multiple operations on DB). I call these methods one after other and all of these DB operations take place in a particular order. Now, is it possible that I can enclose this entire set of method calls in a transaction context? In the sense, all the stored procedures that are fired should be rolled back if a stored procedure fails.

 

Your suggestions are highly appreciated.

 

Thank you,

DNM

  • Administrators
Posted

A Connection object has a BeginTransaction method - this returns a Transaction object; if you assign this to each command's Transaction property then they will all be part of the same transaction.

Alternatively you may want to investigate Component Services under windows (System.EnterpriseServices.dll).

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted
A Connection object has a BeginTransaction method - this returns a Transaction object; if you assign this to each command's Transaction property then they will all be part of the same transaction.

Alternatively you may want to investigate Component Services under windows (System.EnterpriseServices.dll).

 

Thank you for your quick reply PD.

 

However, the problem in my case is that I do not have access to the connection or the command object directly. We have created something called as a Data Access Manager in the DAL that takes care of the connection and the command. So I was wondering if there was something that could treat a set of statements as a transaction. I am not sure if it is possible :(

Posted
either recode the flawed DAL or explicity begin and end the transaction using sql, e.x.: "BEGIN TRANSACTION", "COMMIT", "ROLLBACK", etc. I would prefer you perform the former as you will only be building a city on a swamp by doing the latter.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...