Karol Bladek
Karol Bladek

Reputation: 15

Application Transaction + C# + more than one operation

I would Like to ask you, if there is a way to set some operations into transaction. I have problem such like this:

1) Generate File from data from database 2) Encrypt it 3) Send to server

I would like do it in one transaction. Any failured step 1-3 should cause the cancelling transaction.

Best regards,

Upvotes: 1

Views: 166

Answers (3)

James Westgate
James Westgate

Reputation: 11444

I dont think you need a transaction for this as you only update the database in your last step. Any failure up to that point does not affect any other data from what you describe in your post.

Update: You may want to look at Volatile Resource Managers

Upvotes: 0

Paw Baltzersen
Paw Baltzersen

Reputation: 2752

As curious_geek stated it can be achived with a TransactionScope. But it can be tricky to work with transactions, especially when you want to do more than one type of operation per transaction.

Are you even sure that you need a transaction? Cant you just delete the file again if step 2 or 3 fails?

Upvotes: 0

this. __curious_geek
this. __curious_geek

Reputation: 43217

Yes. Check out TransactionScope and MSDTC.

Upvotes: 1

Related Questions