Home All Groups Group Topic Archive Search About

Multiple Stored Procedure Calls within single transaction

Author
28 Nov 2007 5:52 PM
BostonNole
I am using SQL 2000 and VB.NET (VS 2005).

I have three stored procedure: sp_A, sp_B and sp_C

I need to be able to call sp_A once and sp_B and sp_C 1 to n number of
times all within a single transaction that can be rolled back if any
of the calls to the stored procedures fail.

sp_A - inserts to table ZZZ
sp_B - inserts to table YYY (but needs to be called multiple times)
and is dependent on the primary key being inserted into table ZZZ that
sp_A is inserting into.
sp_C inserts to table QQQ (but needs to be called multiple times) and
is dependent on the primary key being inserted into table ZZZ that
sp_A is inserting into.

I would prefer to use Enterprise Library 3 for my database calls.

Author
28 Nov 2007 7:05 PM
zacks
On Nov 28, 12:52 pm, BostonNole <bostonn***@gmail.com> wrote:
Show quoteHide quote
> I am using SQL 2000 and VB.NET (VS 2005).
>
> I have three stored procedure: sp_A, sp_B and sp_C
>
> I need to be able to call sp_A once and sp_B and sp_C 1 to n number of
> times all within a single transaction that can be rolled back if any
> of the calls to the stored procedures fail.
>
> sp_A - inserts to table ZZZ
> sp_B - inserts to table YYY (but needs to be called multiple times)
> and is dependent on the primary key being inserted into table ZZZ that
> sp_A is inserting into.
> sp_C inserts to table QQQ (but needs to be called multiple times) and
> is dependent on the primary key being inserted into table ZZZ that
> sp_A is inserting into.
>
> I would prefer to use Enterprise Library 3 for my database calls.

Are you expecting someone to write the code for you?

I do not know what Enterprise Library 3 is, but it's easy to do what
you want with ADO.NET. Check out:

https://msdn2.microsoft.com/en-us/library/system.data.odbc.odbctransaction(VS.71).aspx
Author
28 Nov 2007 8:01 PM
BostonNole
On Nov 28, 2:05 pm, za***@construction-imaging.com wrote:
Show quoteHide quote
> On Nov 28, 12:52 pm, BostonNole <bostonn***@gmail.com> wrote:
>
>
>
>
>
> > I am using SQL 2000 and VB.NET (VS 2005).
>
> > I have three stored procedure: sp_A, sp_B and sp_C
>
> > I need to be able to call sp_A once and sp_B and sp_C 1 to n number of
> > times all within a single transaction that can be rolled back if any
> > of the calls to the stored procedures fail.
>
> > sp_A - inserts to table ZZZ
> > sp_B - inserts to table YYY (but needs to be called multiple times)
> > and is dependent on the primary key being inserted into table ZZZ that
> > sp_A is inserting into.
> > sp_C inserts to table QQQ (but needs to be called multiple times) and
> > is dependent on the primary key being inserted into table ZZZ that
> > sp_A is inserting into.
>
> > I would prefer to use Enterprise Library 3 for my database calls.
>
> Are you expecting someone to write the code for you?
>
> I do not know what Enterprise Library 3 is, but it's easy to do what
> you want with ADO.NET. Check out:
>
> https://msdn2.microsoft.com/en-us/library/system.data.odbc.odbctransa...- Hide quoted text -
>
> - Show quoted text -

I am not asking anyone to write any code for me.  Your link is for an
ODBC class that is for .NET 1.1 only.  I am using .NET 2.0.
Author
28 Nov 2007 9:17 PM
Spam Catcher
BostonNole <bostonn***@gmail.com> wrote in news:9fd85aa9-1a88-4a0a-8e1a-
813c63c23***@w34g2000hsg.googlegroups.com:

> I am not asking anyone to write any code for me.  Your link is for an
> ODBC class that is for .NET 1.1 only.  I am using .NET 2.0.

ODBC class is part of the .NET 2.0 framework too.

AFAIK, you can't wrap multiple SPs in a transaction. Each SP has it's own
execution context. But I could be wrong.
Author
28 Nov 2007 9:36 PM
Jack Jackson
On Wed, 28 Nov 2007 12:01:18 -0800 (PST), BostonNole
<bostonn***@gmail.com> wrote:

Show quoteHide quote
>On Nov 28, 2:05 pm, za***@construction-imaging.com wrote:
>> On Nov 28, 12:52 pm, BostonNole <bostonn***@gmail.com> wrote:
>>
>>
>>
>>
>>
>> > I am using SQL 2000 and VB.NET (VS 2005).
>>
>> > I have three stored procedure: sp_A, sp_B and sp_C
>>
>> > I need to be able to call sp_A once and sp_B and sp_C 1 to n number of
>> > times all within a single transaction that can be rolled back if any
>> > of the calls to the stored procedures fail.
>>
>> > sp_A - inserts to table ZZZ
>> > sp_B - inserts to table YYY (but needs to be called multiple times)
>> > and is dependent on the primary key being inserted into table ZZZ that
>> > sp_A is inserting into.
>> > sp_C inserts to table QQQ (but needs to be called multiple times) and
>> > is dependent on the primary key being inserted into table ZZZ that
>> > sp_A is inserting into.
>>
>> > I would prefer to use Enterprise Library 3 for my database calls.
>>
>> Are you expecting someone to write the code for you?
>>
>> I do not know what Enterprise Library 3 is, but it's easy to do what
>> you want with ADO.NET. Check out:
>>
>> https://msdn2.microsoft.com/en-us/library/system.data.odbc.odbctransa...- Hide quoted text -
>>
>> - Show quoted text -
>
>I am not asking anyone to write any code for me.  Your link is for an
>ODBC class that is for .NET 1.1 only.  I am using .NET 2.0.

For native SqlServer the equivalent object is:

<http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqltransaction.aspx>

I have never used Enterprise Library, but Googling for "Enterprise
Library 3 transactions" has some links that might be helpful.
Author
28 Nov 2007 10:19 PM
Chris Dunaway
On Nov 28, 11:52 am, BostonNole <bostonn***@gmail.com> wrote:
Show quoteHide quote
> I am using SQL 2000 and VB.NET (VS 2005).
>
> I have three stored procedure: sp_A, sp_B and sp_C
>
> I need to be able to call sp_A once and sp_B and sp_C 1 to n number of
> times all within a single transaction that can be rolled back if any
> of the calls to the stored procedures fail.
>
> sp_A - inserts to table ZZZ
> sp_B - inserts to table YYY (but needs to be called multiple times)
> and is dependent on the primary key being inserted into table ZZZ that
> sp_A is inserting into.
> sp_C inserts to table QQQ (but needs to be called multiple times) and
> is dependent on the primary key being inserted into table ZZZ that
> sp_A is inserting into.
>
> I would prefer to use Enterprise Library 3 for my database calls.

If you have your Enterprise Library Database object, you can
call .CreateConnection method to get the connection.  Then with the
connection instance, you can call BeginTransaction.

Then for each stored proc you need to call, pass that transaction in
when you call the various ExecuteReader, ExecuteNonQuery, etc.
methods.

Then afterwards, assuming everything went ok, call the Commit method
on the transaction object.

HTH

Chris
Author
29 Nov 2007 12:36 PM
BostonNole
On Nov 28, 5:19 pm, Chris Dunaway <dunaw***@gmail.com> wrote:
Show quoteHide quote
> On Nov 28, 11:52 am, BostonNole <bostonn***@gmail.com> wrote:
>
>
>
>
>
> > I am using SQL 2000 and VB.NET (VS 2005).
>
> > I have three stored procedure: sp_A, sp_B and sp_C
>
> > I need to be able to call sp_A once and sp_B and sp_C 1 to n number of
> > times all within a single transaction that can be rolled back if any
> > of the calls to the stored procedures fail.
>
> > sp_A - inserts to table ZZZ
> > sp_B - inserts to table YYY (but needs to be called multiple times)
> > and is dependent on the primary key being inserted into table ZZZ that
> > sp_A is inserting into.
> > sp_C inserts to table QQQ (but needs to be called multiple times) and
> > is dependent on the primary key being inserted into table ZZZ that
> > sp_A is inserting into.
>
> > I would prefer to use Enterprise Library 3 for my database calls.
>
> If you have your Enterprise Library Database object, you can
> call .CreateConnection method to get the connection.  Then with the
> connection instance, you can call BeginTransaction.
>
> Then for each stored proc you need to call, pass that transaction in
> when you call the various ExecuteReader, ExecuteNonQuery, etc.
> methods.
>
> Then afterwards, assuming everything went ok, call the Commit method
> on the transaction object.
>
> HTH
>
> Chris- Hide quoted text -
>
> - Show quoted text -

Thank you Chris, I think this is exactly what I was looking for.