how to use Begintransaction ?

  • Thread starter Thread starter Jason Shohet
  • Start date Start date
J

Jason Shohet

Page_a.aspx.cs does a loop thru 7 days of the week. W/in the loop, it
makes a call to myService - a webservice - passing in a serialized objDay
(which represents the day's info). The webservice function deserializes
objDay and writes to the db.

Works great. Problem is if 1 of the 7 days fails to write, there's no
rollback functionality. I want it so that if a day doesn't write, none of
the days should write. BeginTransaction is a property of the transaction
object. But my transaction object exists only in the webservice, and that
webservice is killed and recalled every day of the 7 days of the week. So
there's no continuity there. Is there any way to get the rollback
functionality I'm looking for?

The only thing I can think of is somehow get objDay1, objDay2.....objDay7
and pass them ALL at one time to the webservice, which will then be able to
do all the transactions at once with a beginTransaction at the begining....
But this is more complex because actually, we don't always pass in 7 days.
Sometimes the user only modifies 3 days, in which case we only need to write
to the db 3 times.

Any ideas? Thanks
Jason Shohet
 
If you are using web services and want transactional data, you will have to
throw all 7 at once. But, there are other options:

1. Put the days in a temporary table of some sort (not necessarily
#tableName type of temp table, but rather something you will clear out when
all of the data is there). You can then have the data migrated into the
normal structure when the 7th arrives (part of the stored procedure). Clear
out the table of bad records on a daily basis is an option for cleaning.

2. Compile the information into one stream of data and pass that to the web
method. You then control when the data is sent, which is "only when all 7
days are there".


---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
I like the idear of passing in 1 stream of data, with 1-7 day objects
(objDay) in there.
Problem is I don't know if its possible to somehow serialize all the objects
into 1 single string, and deserialize them back into 1 thru 7 individual
objects.

Perhaps a better way is to create our own XML file with nodes, intead of the
objDay objects. This would be much uglier to work with in code however.
The custom class objects are much more elegant....

Thanks again cowboy
 
Back
Top