?
Solved

StartTransaction giving Error " Already in Transaction " .

Posted on 2003-03-21
4
Medium Priority
?
414 Views
Last Modified: 2010-04-04
I am doing  a 3 tier application on Delphi(MIDAS) with MSSql as backend. I would like to insert/update and edit the datas of master and detail tables with an active transaction ,so that i can commit or rollback, if there is any error.

I have written in the after post event the following code.

   DataModule.SockectConnection.AppServer.StartTransaction;
   { this is a TLB Method that checks if any transaction is active and if not Starts a new Transaction " if not DataBase.InTransaction then DataBase.StartTransaction;" }
   try
    ClientDataSet_Master.ApplyUpdates(-1);
    ClientDataSet_Detail.ApplyUpdates(-1);
    DataModule.SockectConnection.AppServer.Commit;
    { this is a TLB Method that checks if any transaction is active and if Commits the active transaction " if DataBase.InTransaction then DataBase.Commit;"}
   except
    DataModule.SockectConnection.AppServer.Rollback;
    { this is a TLB Method that checks if any transaction is active and if Rollbacks the active transaction " if DataBase.InTransaction then DataBase.Rollback;"}  
   end;
                    But it gives an error 'Already InTrasaction ' when the control goes to  the line
     ClientDataSet_Master.ApplyUpdates(-1);

   What might be the problem ? Is it due to the back-end (MSSQL ) that has a default Transaction ??
0
Comment
Question by:vineeth_mathew
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 1

Accepted Solution

by:
nafeelm earned 300 total points
ID: 8269873

try setting the StatTransaction in Before Post event

in the AfterPost event let the following be:
  try
   //ClientDataSet_Master.ApplyUpdates(-1); you cannot put this here
   ClientDataSet_Detail.ApplyUpdates(-1);
   DataModule.SockectConnection.AppServer.Commit;
  except
   DataModule.SockectConnection.AppServer.Rollback;
  end;

also set the RollBack event in AfterCancel event just incase the user cancels the record!
0
 

Expert Comment

by:CleanupPing
ID: 9316644
vineeth_mathew:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month12 days, 21 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question