Home commit on MySql + Zeos lib
Reply: 0

commit on MySql + Zeos lib

user852
1#
user852 Published in May 21, 2018, 6:35 pm

I use next code to post some records on a non autocommin connection:

ZConnection1.AutoCommit := False;

  try
    ZTable1.Insert;
    ZTable1.FieldByName('name').AsString := 'John Doe';
    ZTable1.Post;
    ZConnection1.Commit;
  except
    ZConnection1.Rollback;
  end;

When I run this code nothing is saved on my database.

After I try next code ...

ZConnection1.AutoCommit := False;

   with ZQuery1 do begin
      SQL.Text := 'INSERT INTO mytable (name) values ("John Doe")';
      ExecSQL;
      SQL.Text := SQL.Text + 'COMMIT' ;
      try
        ExecSQL;
      except
        SQL.Text := 'ROLLBACK';
        ExecSQL;
      end;
    end;

... all work perfect.

What I do wrong on first case? I use Delphi6, MySql, Zeos library and InnoDB table.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.306069 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO