473,396 Members | 1,784 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,396 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 3877

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 (...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.