473,698 Members | 2,086 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Transaction object question

REB
If I create a transaction object for rolling back a insert query in the on
click event of a form button can the transaction be tracked across other
functions?

For example:

private void btnSaveDriver_C lick(object sender, System.EventArg s e)

{

Create transaction object

Execute a insert query into a primary table

Call_Funtion_On e(int primary_key_fro m_intial_insert )

Call_Funtion_Tw o(int Primarykey)

on error rollback everything exectued above

}

Call_Funtion_On e(int Primarykey)

{

Execute query to insert data in a related table using key passed into the
function

}

Call_Funtion_Tw o(int Primarykey)

{

Execute query to insert data in a related table using key passed into the
function

}

I hope what I am asking makes sense, if not please let me know and I will
try to elaborate further.
Nov 18 '05 #1
1 1343
Hi,

To track the transaction, you will need to pass a
reference to the transaction object to the functions you
call.

A better way to do it might be like this:

try{
create connection
create transaction

call func1() //performs inserts/updates
call func2() //performs inserts/updates
...
}catch(Exceptio n x){
transaction.Rol lback()
}
transaction.Com mit()

OR
you could inherit your business classes from
ServicedCompone nt and use the COM+ features for
transaction management.

HTH
Regards
Harsh Thakur
-----Original Message-----
If I create a transaction object for rolling back a insert query in the onclick event of a form button can the transaction be tracked across otherfunctions?

For example:

private void btnSaveDriver_C lick(object sender, System.EventArg s e)
{

Create transaction object

Execute a insert query into a primary table

Call_Funtion_O ne(int primary_key_fro m_intial_insert )

Call_Funtion_T wo(int Primarykey)

on error rollback everything exectued above

}

Call_Funtion_O ne(int Primarykey)

{

Execute query to insert data in a related table using key passed into thefunction

}

Call_Funtion_T wo(int Primarykey)

{

Execute query to insert data in a related table using key passed into thefunction

}

I hope what I am asking makes sense, if not please let me know and I willtry to elaborate further.
.

Nov 18 '05 #2

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

Similar topics

3
2578
by: Alan | last post by:
Gidday people, I had a bit of a problem this morning. I think I've got it sorted now, but I wonder if anyone can shed some light. I have a plain VBS WHS file that instantiates a component that controls an interface file import process. This component, Controller, is part of FinInterface.dll, and instantiates another component, Implementor (same dll), that does the actual data access (an insert into a FinanceDataImports table, and then...
2
2373
by: Deepak Mehta | last post by:
i have to update two tables from ASP pages with same data but i want that both of them should be updated at one time. If either of them is not updated then my transaction should roll back.I want this thing to be in a stored procedure. so that i have to write an execute statement only on the ASP page and pass the parameters. Looking forward for ur reply DEEPAK
0
2457
by: DotNetJunkies User | last post by:
I am writing a distributed transaction code. My current scenario include a client database(Suppose client- having 4 main database) which can be installed anywhere which would connect to a public database placed at ISP datacentre(Suppose Server- having 2 database). this server database is added to client as linked server through vb.net interface. i have a transmission routine which transmitts the data from the client to Server and update client...
3
8670
by: Eric Porter | last post by:
Dear All, I have a VB6.COM program using a VB6.COM DLL, which in turn uses ADODB that performs various bits of SQL. I have re-written the VB6.COM DLL in C#.NET (with a VB6 shell), which uses the ADODB.Interop library supplied with .NET. The VB6.COM program above calls this C#.NET library in an effort to perform the equivalent functionality.
4
4148
by: Rahul Anand | last post by:
Getting SQL Exception when trying to implement Connection based Trasaction using SQL Helper class. I am using the follwing function to execute my stored procs: -=-=-=- ExecuteScalar(ByVal transaction As SqlTransaction, _ ByVal spName As String, _ ByVal ParamArray parameterValues() As Object)
0
1118
by: samiam | last post by:
Here are my requirements of the web service (.NET 1.1, XP/2003) (1) It needs to call a COM+ application that has already been written and deployed. The web service essentially becomes a client to the COM+ application. (2) The web service needs to initiate a new transaction when calling the COM+ application, then it needs to complete or abort EXPLICITLY. A million dollar question.....
0
1477
by: tony | last post by:
Hello! Below I have three methods it's SavePost, SavePostSetUpTableFlg and SavePostBlowStepFlg. I want to use transaction to keep the data synchronized. All or nothing must be executed. When I created the OleDbConnection and the OleDbAdapter I used the toolbox and the wizard. This method SavePost is just calling SavePostSetUpTableFlg and
3
2040
by: GaryDean | last post by:
I'm using TransactionScope as follows... using TransactionScope myScope = new TransactionScope()) { using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = GlobalData.connString; conn.Open(); ...................code that does db work myScope.Complete();
10
1500
by: Lit | last post by:
Hi, using ADO.NET 2.0, VS.NET 2005, SQL2005 I need to execute several Stored Procedures under one transaction. Can I use just one command/transaction or have to use multiple ( then commit or rollback all ) How does it work with ADO.NET Ado.Tran SP1 Called
0
8600
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9155
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9018
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8858
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7711
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5859
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4614
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3038
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 we have to send another system
3
1997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.