Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.Net transaction question

Status
Not open for further replies.

jsteph

Technical User
Oct 24, 2002
2,562
US
Hi all,
I wasn't sure if this was more of a .Net question or SQL, it seemed more .Net but apologies if this is the wrong forum.

So I have a new third party database which provides a web service which I'm bound by contract to use to update any of their data tables in this sql-2008 R2 db (we host the db in-house).

So we can write our own .Net code for this app, providing we use the webservices (we have no source code, just the .dll) to update a table, but we want auditing as well. They didn't have an audit table so we built our own audit table (which we can update as we wish), and want to insert to that when we update certain "core" data.

However, I want the audit insert and the webservice update all wrapped in a transaction. I've always felt a little queasy about opening a transaction from .Net code, so I've always done transaction processing within a stored proc but with this new system I don't have that option.

So is there a best practice for this type of thing? Is this "done", ie, is it common practice to open a transaction from .Net code, then call webservices, then do your own updates, whatever, then commit from the .Net code, even if the webservice may be doing it's own thing with a transaction?

Sorry for seeming dense about this, I have never really done any transaction processing via .net before.
Thanks,
--Jim
 
All that you have said is true. Transactions should be handled in SQL. However, you don't have that control or access, so your only option is a .NET transaction. I have done them in past. They do server their purpose, and this is exactly the case. Just make sure you are using the latest transaction syntax for the version of the framework you are using. I know somewhere along the line, they changed the way to do transactions(and syntax). Somewhere around 2.0 I think, but not exactly sure. Just Google for some examples using the version of the framework you are using.
 
jbenson,
Thanks very much, I will look into that syntax and see what's there,
--Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top