473,416 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

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_Click(object sender, System.EventArgs e)

{

Create transaction object

Execute a insert query into a primary table

Call_Funtion_One(int primary_key_from_intial_insert)

Call_Funtion_Two(int Primarykey)

on error rollback everything exectued above

}

Call_Funtion_One(int Primarykey)

{

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

}

Call_Funtion_Two(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 1318
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(Exception x){
transaction.Rollback()
}
transaction.Commit()

OR
you could inherit your business classes from
ServicedComponent 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_Click(object sender, System.EventArgs e)
{

Create transaction object

Execute a insert query into a primary table

Call_Funtion_One(int primary_key_from_intial_insert)

Call_Funtion_Two(int Primarykey)

on error rollback everything exectued above

}

Call_Funtion_One(int Primarykey)

{

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

}

Call_Funtion_Two(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
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...
2
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...
0
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...
3
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...
4
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...
0
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...
0
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...
3
by: GaryDean | last post by:
I'm using TransactionScope as follows... using TransactionScope myScope = new TransactionScope()) { using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString =...
10
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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
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...
0
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...
0
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...

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.