![]() |
|
|
Welcome to the { mindfrost82.com } forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
RE: C# File + DB Transaction
Wrap the actions in a
using(System.Transactions.TransactionScope txScope = new TransactionScope()){ try{ ReadFile() InsertToDb() DeleteFile() txScope.Complete(); }catch(AnyOldException ex){ LogError(); } } -- Ciaran O''Donnell http://wannabedeveloper.spaces.live.com "Chris Fink" wrote: > I have the following requirements and am looking to make this into a c# > transaction. > > 1. Read from a file into a memory stream > 2. Insert the stream into a DB > 3. Delete the file > > Is it possible to perform a transaction on both a File action and a DB > insert? > > A transaction will ensure that if an error occurs in step 3, the insert will > not commit, etc. All three steps must succeed, otherwise the transaction > should rollback and notify of an error. > > Any assistance is appreciated. > > Thanks > |
![]() |
|
| Thread Tools | Search this Thread |
| Display Modes | |
|
|