How to cancel an insert using TMyTable

How to cancel an insert using TMyTable

Postby Hans » Fri 28 Oct 2005 14:53

Hi,
Before I insert a new record I want to verify if the record already exists. My approach is that I catch the BeforePost event, query the table and if record already exists just CANCEL the insert using TMyTable.Cancel.

However, after calling cancel the insert is not stopped but executed. Is it possible to abort the post? Or cannot I use the events for this purpose and should I validate the database before a Post is executed?

(The nice thing of using the BeforePost Event is, that I validate on one location.)

best regards,
hans
Hans
 
Posts: 52
Joined: Wed 24 Aug 2005 20:05

Postby GEswin » Fri 28 Oct 2005 16:14

Just call
Code: Select all
Abort;
GEswin
 
Posts: 186
Joined: Wed 03 Nov 2004 16:57
Location: Spain

Postby Ikar » Mon 31 Oct 2005 15:10

GEswin is absolutely right. Moreover, you can crash your application by calling Cancel in OnBeforePost event handler.
Ikar
 
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Postby Hans » Mon 31 Oct 2005 18:38

Yes, works fine. Thanks!!

best regards,
Hans
Hans
 
Posts: 52
Joined: Wed 24 Aug 2005 20:05


Return to MySQL Data Access Components