Simple question re insert and update

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
KevinS
Posts: 2
Joined: Thu 17 Mar 2011 17:28

Simple question re insert and update

Post by KevinS » Sat 19 Mar 2011 04:01

How can I find out immediately whether an INSERT or UPDATE operation has been successful, since they both return a Recordcount of 0.

For example,

sql := 'INSERT INTO table . . . '
execute;

Success := ??????


I guess I could trap the exception, but is there some other way?

AndreyZ

Post by AndreyZ » Mon 21 Mar 2011 09:46

Hello,

Besides exceptions, you can use the RowsAffected property, which is used to indicate the number of rows which were inserted, updated, or deleted during the last query operation. For more information please read the MyDAC documentation.

KevinS
Posts: 2
Joined: Thu 17 Mar 2011 17:28

Post by KevinS » Mon 21 Mar 2011 14:11

AndreyZ wrote:RowsAffected property.
Thanks, that's exactly what I wanted to know.

AndreyZ

Post by AndreyZ » Mon 21 Mar 2011 14:19

It is good to see that this problem was solved. If any other questions come up, please contact us.

Post Reply