|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Multiple Stored Procedure Calls within single transactionI 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. On Nov 28, 12:52 pm, BostonNole <bostonn***@gmail.com> wrote:
Show quoteHide quote > I am using SQL 2000 and VB.NET (VS 2005). Are you expecting someone to write the code for you?> > 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. 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 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 not asking anyone to write any code for me. Your link is for an> > > > > > > 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 - ODBC class that is for .NET 1.1 only. I am using .NET 2.0. 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 is part of the .NET 2.0 framework too.> ODBC class that is for .NET 1.1 only. I am using .NET 2.0. AFAIK, you can't wrap multiple SPs in a transaction. Each SP has it's own execution context. But I could be wrong. 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: For native SqlServer the equivalent object is:>> 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. <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. On Nov 28, 11:52 am, BostonNole <bostonn***@gmail.com> wrote:
Show quoteHide quote > I am using SQL 2000 and VB.NET (VS 2005). If you have your Enterprise Library Database object, you can> > 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. 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 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: Thank you Chris, I think this is exactly what I was looking for.> > > > > > > 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 -
Simple Pulbic Variable
Exclude code of my application Vb.Net/SQL slowdown sort two arrays as one? Copying files with progress bar How to stop disabled text boxes being greyed out VB2008 changes? VB.NET desktop equivalent to asp.net stylesheets Multi language tooltips in Windows forms Num records returned from query |
|||||||||||||||||||||||