473,487 Members | 2,466 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

transactions

I wish to do a series of inserts on a sql server database in the context of
a transaction. The inserts will be done as a series of stored procedure
calls. I wish to be able to rollback any inserts should one fail.

A quick google on ".net transactions" and the following page comes up:
http://samples.gotdotnet.com/quickst...nsactions.aspx

It says basically that the class System.EnterpriseServices.ContextUtil is
the chap for the job. However on looking at the EnterpriseServices
namespace, it seems to be full of classes related to COM components. Is
this definately the correct class to use for the job?
Also, the above page describes using the <%@transaction=required%> page
directive in asp.net to set the transaction scope and level. What would
happen if a non asp.net program tried to use transactions? Surely there
must be a programmatic way of doing this too?

Am I barking up the wrong tree with this?

Many thanks
Iain A. Mcleod
Nov 22 '05 #1
3 2223
Iain,

If it is a purely database transaction that you wish to control, I would
recommend ado.net transactions or even transactions within SQL Server to
handle it.

System.EnterpriseServices is what used to be COM+. Actually it is a little
bit more than that - it is in .NET now, and has a few .NET like things in
it. Plus a lot of it is now managed code. One of the things enterprise
services lets you do is to enlist any task (even non - database) into an MTS
transaction. The ASP.NET or even Classic ASP page which has a directive
<%@transaction=required%> specified; is another example of a worker process
that must instantiate a new transaction before it runs. As you might have
already guessed by now, any worker process can enlist itself in a new or
existing transaction.

EnterpriseServices gives you a *lot* more than transactions only. It gives
you instance pooling/creation/queued components/LCEs/Messaging . quite a
long list actually.

What I am driving at is, COM+ and enterprise services are topics that entire
books have been written about. They are a lot more than meets the eye and
yes they are a very powerful concept and should not be ignored - but for
your requirement - check and see if you can satisfy that with ADO.NET
transactions or even SQL Server transactions; before you look at
msdtc/mtc/enterprise services. What's more, there could be many times that
deploying applications that use EnterpriseServices could be a pain the
booty. This might not be an issue for a server, but for desktop client apps
it becomes an unreal hell. I must be clear though - EnterpriseServices rock;
but killing a mosquito with a hand grenade is not the wisest thing to do.

Should you desire, you can find more information on using ADO.NET with
EnterpriseServices in my book - Chapter #12. Another really good book I like
on Enterprise Services is written by Juwal Lowy.

Regards,

- Sahil Malik
You can reach me thru my blog http://www.dotnetjunkies.com/weblog/sahilmalik


"Iain Mcleod" <mc******@dcs.gla.ac.uk> wrote in message
news:uX**************@TK2MSFTNGP15.phx.gbl...
I wish to do a series of inserts on a sql server database in the context of
a transaction. The inserts will be done as a series of stored procedure
calls. I wish to be able to rollback any inserts should one fail.

A quick google on ".net transactions" and the following page comes up:
http://samples.gotdotnet.com/quickst...nsactions.aspx

It says basically that the class System.EnterpriseServices.ContextUtil is
the chap for the job. However on looking at the EnterpriseServices
namespace, it seems to be full of classes related to COM components. Is
this definately the correct class to use for the job?
Also, the above page describes using the <%@transaction=required%> page
directive in asp.net to set the transaction scope and level. What would
happen if a non asp.net program tried to use transactions? Surely there
must be a programmatic way of doing this too?

Am I barking up the wrong tree with this?

Many thanks
Iain A. Mcleod

Nov 22 '05 #2
Thank you Sahil. I thought the com+/mts thingy was a bit of an overkill.
I googled on your suggestion of ado.net transactions and got the following
code:
SqlTransaction objTransaction = objConnection.BeginTransaction();

Perfect: It was indeed the SqlTransaction class I was looking for :-).

I take it that I can use this with stored procedures (anti sqlinjection) as
well as with ad-hoc sql as in the following pseudocode?

try
begin transaction
executeNonQuery (storedproc1, params)
executeNonQuery (storedproc2, params)
commit transaction
catch ex as exception
roll back transaction
end try

Apologies if this seems obvious, I'm a Java programmer learning .net :)

Regards
Iain

"Sahil Malik" <co*****************@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Iain,

If it is a purely database transaction that you wish to control, I would
recommend ado.net transactions or even transactions within SQL Server to
handle it.

System.EnterpriseServices is what used to be COM+. Actually it is a little
bit more than that - it is in .NET now, and has a few .NET like things in
it. Plus a lot of it is now managed code. One of the things enterprise
services lets you do is to enlist any task (even non - database) into an
MTS transaction. The ASP.NET or even Classic ASP page which has a
directive <%@transaction=required%> specified; is another example of a
worker process that must instantiate a new transaction before it runs. As
you might have already guessed by now, any worker process can enlist
itself in a new or existing transaction.

EnterpriseServices gives you a *lot* more than transactions only. It gives
you instance pooling/creation/queued components/LCEs/Messaging . quite a
long list actually.

What I am driving at is, COM+ and enterprise services are topics that
entire books have been written about. They are a lot more than meets the
eye and yes they are a very powerful concept and should not be ignored -
but for your requirement - check and see if you can satisfy that with
ADO.NET transactions or even SQL Server transactions; before you look at
msdtc/mtc/enterprise services. What's more, there could be many times that
deploying applications that use EnterpriseServices could be a pain the
booty. This might not be an issue for a server, but for desktop client
apps it becomes an unreal hell. I must be clear though -
EnterpriseServices rock; but killing a mosquito with a hand grenade is not
the wisest thing to do.

Should you desire, you can find more information on using ADO.NET with
EnterpriseServices in my book - Chapter #12. Another really good book I
like on Enterprise Services is written by Juwal Lowy.

Regards,

- Sahil Malik
You can reach me thru my blog
http://www.dotnetjunkies.com/weblog/sahilmalik


"Iain Mcleod" <mc******@dcs.gla.ac.uk> wrote in message
news:uX**************@TK2MSFTNGP15.phx.gbl...
I wish to do a series of inserts on a sql server database in the context
of a transaction. The inserts will be done as a series of stored
procedure calls. I wish to be able to rollback any inserts should one
fail.

A quick google on ".net transactions" and the following page comes up:
http://samples.gotdotnet.com/quickst...nsactions.aspx

It says basically that the class System.EnterpriseServices.ContextUtil is
the chap for the job. However on looking at the EnterpriseServices
namespace, it seems to be full of classes related to COM components. Is
this definately the correct class to use for the job?
Also, the above page describes using the <%@transaction=required%> page
directive in asp.net to set the transaction scope and level. What would
happen if a non asp.net program tried to use transactions? Surely there
must be a programmatic way of doing this too?

Am I barking up the wrong tree with this?

Many thanks
Iain A. Mcleod


Nov 22 '05 #3
Yes you can use it with stored procs. :)

- Sahil Malik
You can reach me thru my blog http://www.dotnetjunkies.com/weblog/sahilmalik


"Iain Mcleod" <mc******@dcs.gla.ac.uk> wrote in message
news:uT*************@TK2MSFTNGP11.phx.gbl...
Thank you Sahil. I thought the com+/mts thingy was a bit of an overkill.
I googled on your suggestion of ado.net transactions and got the following
code:
SqlTransaction objTransaction = objConnection.BeginTransaction();

Perfect: It was indeed the SqlTransaction class I was looking for :-).

I take it that I can use this with stored procedures (anti sqlinjection)
as well as with ad-hoc sql as in the following pseudocode?

try
begin transaction
executeNonQuery (storedproc1, params)
executeNonQuery (storedproc2, params)
commit transaction
catch ex as exception
roll back transaction
end try

Apologies if this seems obvious, I'm a Java programmer learning .net :)

Regards
Iain

"Sahil Malik" <co*****************@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Iain,

If it is a purely database transaction that you wish to control, I would
recommend ado.net transactions or even transactions within SQL Server to
handle it.

System.EnterpriseServices is what used to be COM+. Actually it is a
little bit more than that - it is in .NET now, and has a few .NET like
things in it. Plus a lot of it is now managed code. One of the things
enterprise services lets you do is to enlist any task (even non -
database) into an MTS transaction. The ASP.NET or even Classic ASP page
which has a directive <%@transaction=required%> specified; is another
example of a worker process that must instantiate a new transaction
before it runs. As you might have already guessed by now, any worker
process can enlist itself in a new or existing transaction.

EnterpriseServices gives you a *lot* more than transactions only. It
gives you instance pooling/creation/queued components/LCEs/Messaging .
quite a long list actually.

What I am driving at is, COM+ and enterprise services are topics that
entire books have been written about. They are a lot more than meets the
eye and yes they are a very powerful concept and should not be ignored -
but for your requirement - check and see if you can satisfy that with
ADO.NET transactions or even SQL Server transactions; before you look at
msdtc/mtc/enterprise services. What's more, there could be many times
that deploying applications that use EnterpriseServices could be a pain
the booty. This might not be an issue for a server, but for desktop
client apps it becomes an unreal hell. I must be clear though -
EnterpriseServices rock; but killing a mosquito with a hand grenade is
not the wisest thing to do.

Should you desire, you can find more information on using ADO.NET with
EnterpriseServices in my book - Chapter #12. Another really good book I
like on Enterprise Services is written by Juwal Lowy.

Regards,

- Sahil Malik
You can reach me thru my blog
http://www.dotnetjunkies.com/weblog/sahilmalik


"Iain Mcleod" <mc******@dcs.gla.ac.uk> wrote in message
news:uX**************@TK2MSFTNGP15.phx.gbl...
I wish to do a series of inserts on a sql server database in the context
of a transaction. The inserts will be done as a series of stored
procedure calls. I wish to be able to rollback any inserts should one
fail.

A quick google on ".net transactions" and the following page comes up:
http://samples.gotdotnet.com/quickst...nsactions.aspx

It says basically that the class System.EnterpriseServices.ContextUtil
is the chap for the job. However on looking at the EnterpriseServices
namespace, it seems to be full of classes related to COM components. Is
this definately the correct class to use for the job?
Also, the above page describes using the <%@transaction=required%> page
directive in asp.net to set the transaction scope and level. What would
happen if a non asp.net program tried to use transactions? Surely there
must be a programmatic way of doing this too?

Am I barking up the wrong tree with this?

Many thanks
Iain A. Mcleod



Nov 22 '05 #4

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

Similar topics

6
2566
by: Christopher J. Bottaro | last post by:
Hi, Why is there no support for explicit transactions in the DB API? I mean like transaction() to start the trans and commit() and rollback() would end the trans or something. The reason why I...
7
2362
by: Richard Maher | last post by:
Hi, I am seeking the help of volunteers to test some software that I've developed which facilitates distributed two-phase commit transactions, encompassing any resource manager (e.g. SQL/Server...
3
393
by: Iain Mcleod | last post by:
I wish to do a series of inserts on a sql server database in the context of a transaction. The inserts will be done as a series of stored procedure calls. I wish to be able to rollback any...
6
2784
by: Terri | last post by:
I have a table called Transactions with 3 fields: ID, Date, and Amount. Each ID can have multiple transactions in one particular year. An ID might not have had any transactions in recent years. ...
9
2030
by: TD | last post by:
I am trying to add transactions to my code. The original code worked fine until I followed an example to setup transactions, now the code does strange things, but no error messages. Could...
11
12966
by: Mike P | last post by:
I've been using C# transactions for a while and had no problems with them. Using try catch blocks I can trap basically all possible errors and rollback all necessary data. Over the last few...
1
1397
by: mark | last post by:
In Java, you can use JBoss or similar to host EJB that will manage your transactions for you. You could, of course, write your own transactions using JDBC. In .NET, we can specify our own...
0
1323
radcaesar
by: radcaesar | last post by:
Customer Table ID Name Address City Phone 1 Vijay Stores 6,Gandhi Road Pondy 0413-276564 2 Ram Stores 3, MG Road, Pondicherry 0413-29543756 3 Balu Papers 3, RG...
2
2678
by: Sridhar | last post by:
Hi, I am trying to implement sql transactions. But I am not knowing how to do that. I created a data access layer which contains methods to select/insert/update tables in a database. I have also...
12
2017
by: Rami | last post by:
I have some requirement for an automated payment system. The system has four machines setup as follows: 1- Two machines have a clustered database. 2- Two machines have a .net business logic...
0
7105
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7132
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7180
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...
1
6846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5439
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4870
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4564
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1381
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
600
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.