Print Page | Close Window

Set Transaction error

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1837
Printed Date: 19-Apr-2024 at 12:23pm


Topic: Set Transaction error
Posted By: Neela
Subject: Set Transaction error
Date Posted: 21-May-2010 at 8:27am
Hello,
 
I am getting an error "SET TRANSACTION must be first statement of transaction." when I try to save an entity to the database. Below is the code. Please let me know in what circumstances this error would generate.
I appreciate your help. Thank you.
 
public static void SetMonth(OssMarginEntityManager em, DateTime beginDate, DateTime endDate)
        {
            var item = (from o in em.OssMarginMonths where (o.OssMarginMonthId == 1) select o).FirstOrNullEntity();
            if (item != null && item.OssMarginMonthId  >  0)
            {
                item.BeginDate = beginDate;
                item.EndDate = endDate;
                var entities = new List<Entity> { item };
                em.SaveChangesAsync(entities, SetMonthCallback, null);
            }
        }



Replies:
Posted By: ting
Date Posted: 21-May-2010 at 4:22pm

Sadly, I don't have quite enough to go on. Can we simplify the problem?

Set aside the decision logic. Can you write the simplest possible SL application that (a) reads an OssMarginMonth, (b) modifies it, and (c) saves it?
 
The application should do nothing else except launch, read, modify, and save.
 
If you still get the error, we'll ask that you send us something we can investigate here. Unfortunately, we can't manage an entire application. We need to work with something a bit more focused. Accordingly, we'll ask that you
 
1) Strip it down to a one table database with just OssMarginMonth
1a) Enter a few rows of sample data
2) Rebuild the sample (as just described) to talk to that toy database
3) Reproduce the error again
4) Zip it all up and send it to us
 
We regret that you're having trouble. Hope we can get this resolved quickly.



Print Page | Close Window