RE: C# File + DB Transaction

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?Q2lhcmFuIE8nJ0Rvbm5lbGw=?=

    RE: C# File + DB Transaction

    Wrap the actions in a
    using(System.Tr ansactions.Tran sactionScope txScope = new TransactionScop e()){
    try{
    ReadFile()
    InsertToDb()
    DeleteFile()
    txScope.Complet e();
    }catch(AnyOldEx ception ex){
    LogError();
    }
    }
    --
    Ciaran O''Donnell
    try{ Life(); } catch (TooDifficultException) { throw Toys(); }



    "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
    >
Working...