Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 296
  • Last Modified:

updating database table using transaction

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
monz
Asked:
monz
  • 2
1 Solution
 
linus66Commented:
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
 
monzAuthor Commented:
nothing is changed
when i call the post metod i receive the same erro message
0
 
linus66Commented:
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
 
CleanupPingCommented:
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now