473,387 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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
Oct 15 '08 #1
0 1062

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Bucfan1 | last post by:
Hello All, I have been encountering trouble with a SQL Server 2000 Transaction log file, mainly with the constant growth and lack of the autoshrink option. Here are the details: 1.) OS is...
3
by: Daniel Xiao | last post by:
I have set the initial size of the log file for a database to 1M, the maximum size is unrestricted, and the increase rate is 10%. However, when I attempt to delete thousands of rows, the error is...
16
by: Michael | last post by:
I have a data application in a2k that I need to create two fixed width text files and then combine them to a single file The first file is header information and the second is transaction data. ...
2
by: alan_sec | last post by:
Can someone tell me what this exception means: Row or object SEKVENCE in EXTLOG001 type *FILE in use Alan
2
by: msuk | last post by:
All, I have a byte array that I save as a file to disk, is there anyway of saving the file as a transaction. For example I save the file to disk and virus scan it, if no virus is found I...
1
by: Hubert Fröhlich | last post by:
Hi list, when doing a large Insert I get in the logfile: 2004-08-03 07:23:46 LOG: recycled transaction log file "000001BA000000BD" 2004-08-03 07:34:00 LOG: recycled transaction log file...
4
by: Trevor Best | last post by:
I have a client with 150MB database, the transaction log file is nearly 23GB. It's a PITA for me to backup his data and restore it on my server as it takes about 30 minutes to restore as it...
2
by: =?Utf-8?B?Q2hyaXMgRmluaw==?= | last post by:
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...
9
by: techking | last post by:
Hello ive written a program but it does not want to read from a referenced text file. i wonder if anyone can tell me what the problem is? below is the source code and after that is the text file. ...
5
by: joeferns79 | last post by:
I have this log ... - infrastructure:ID_UNHANDLED: An un-handled server exception occu rred. Please contact your administrator. at...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.