472,776 Members | 2,540 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

The transaction is either not associated with the current connection or has been completed

Hi

i'm using Enterprise Library for .NET Framework 2.0 january 2006 - i
really like it but, i have a problem with transactions

i'm trying to save 2 object company and user in a transaction ( when
you register on a web site)

my user object as a company object, i fill them up with info

when i save i call user.company.save first passing it a transaction
and then i do user.save passing it the transaction
the problem is that i get the error 'The transaction is either not
associated with the current connection or has been completed' , i
don't know why because t i associate the the connection and the
transaction is not completed

here is some code

user class code :

Save
{
Database db = DatabaseFactory.CreateDatabase();
using (DbConnection cnn = db.CreateConnection())
{
cnn.Open();
DbTransaction tran = cnn.BeginTransaction();
try
{
Company.Save(tran);
Add(tran)
.....
}
}
}
Add(DbTransaction tran)
{
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetStoredProcCommand(cmdname);
cmd.Connection = tran.Connection;
cmd.Transaction = tran;
......
db.ExecuteNonQuery(cmd);
....
}

Company class:
Save(tran)
{
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetStoredProcCommand(cmdName);
cmd.Connection = tran.Connection;
cmd.Transaction = tran;
....
db.ExecuteNonQuery(cmd); // <-- this is where i get the exception
....
}

any idea would help a lot
i have tried to pass as parameters the db(Database object) and / or
the cnn object
always getting the same error
I'm thinking of moving to an other DAL;

thanks

May 21 '07 #1
0 3625

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

Similar topics

7
by: Abdul-Wahid Paterson | last post by:
Hi, I have had a site working for the last 2 years and have had no problems until at the weekend I replace my database server with a newer one. The database migration went like a dream and I had...
2
by: Joe Weinstein | last post by:
Hi, and thanks in advance... I have about zero experience with DB2, and I need help diagnosing a transaction-related problem... What SQL can I run to find what transactions (XA) may be in process...
2
by: John Lee | last post by:
Hi, I have few questions related to .NET 2.0 TransactionScope class behavior: 1. Check Transaction.Current.TransactionInformation.DistributedIdentifier to identify if distributed transaction...
15
by: Zeng | last post by:
Hi, The bigger my C# web-application gets, the more places I need to put in the tedious retrying block of code to make sure operations that can run into database deadlocks are re-run (retried)...
2
by: Dano | last post by:
Hi all! Perhaps a wise soul can help me here. I have an insert routine for an ASP.Net application and it works fine, but I decided to test the transaction rollback capabilities by stopping the...
0
by: DaveT | last post by:
I am trying to find help on how to properly use ado transactions across multilple classes that each call a method to save data in their respective database table. The current method created worked...
9
by: Andy_Khosravi | last post by:
I'm an entry-level VBA programmer that is almost entirely self-taught. This means that while I have adequate knowledge of VBA in some areas, I have several gaps in others that may seem obvious to...
2
by: Christian Stooker | last post by:
Part one: ====== Hi ! I want to use SQLite database like the FireBird database: with big isolation level. What's that meaning ? I have an application that periodically check some input...
0
by: fredd00 | last post by:
Hi i'm using Enterprise Library for .NET Framework 2.0 january 2006 - i really like it but, i have a problem with transactions i'm trying to save 2 object company and user in a transaction (...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?

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.