?
Solved

updating database table using transaction

Posted on 2003-03-20
6
Medium Priority
?
295 Views
Last Modified: 2010-04-04
i use delphi 5

i want update a database table using database transactions

i have a datamodule with a database component (database1) and some table components (table1, table2...)

i wrote for exemple

datamodule.table1.database.starttransaction;
datamodule.table1.edit;
datamodule.table1.fieldbyname('NAME1').AsString := 'something';
......
datamodule.table1.post;
datamodule.table1.database.commit;

the error message i receive is "Nested transaction not supported"

why?

is there an implicit call to starttransaction inside the edit procedure?


0
Comment
Question by:monz
[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
  • 2
6 Comments
 

Expert Comment

by:linus66
ID: 8173662
when you start transaction see to that you don have another transaction pending. you can always prevent this by a commit before starttransaction also do a try except routine to handle exceptions...
try
  if datamodule.table1.database.InTransaction Then
    datamodule.table1.database.Commit;

  datamodule.table1.database.starttransaction();

  datamodule.table1.edit();
  datamodule.table1.First();
  while not datamodule.table1.eof do
  Begin
    datamodule.table1.fieldbyname('NAME1').AsString := 'something';
    datamodule.table1.post();
  End;
  if datamodule.table1.database.InTransaction Then
   datamodule.table1.database.commit();
except
  on e:exception do
  begin
     ShowMessage(e.message)
     datamodule.table1.database.RollBack();
  end;
end;

hope it gives a hunt to you..

0
 

Author Comment

by:monz
ID: 8209468
nothing is changed
when i call the post metod i receive the same erro message
0
 

Accepted Solution

by:
linus66 earned 200 total points
ID: 8213418
Hello.
If you are using bde be sure that the parameter on database alias sqlpassthru mode is set to shared noautocommit.
if you are using paradox tables, they dont support transactions.
if this doesn't help tell me a little more about your configuration(database connectiontype etc).
Good luck..
0
 

Expert Comment

by:CleanupPing
ID: 9316663
monz:
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month12 days, 22 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