Topic: OnSQLException
I am wondering if I can just put the following script of a function in a button click and not call the function
function OnSQLException(Sender: TObject; Msg: string; SQL: string): boolean;
begin
// exception from button frmStoixeia.Button4
if Sender = frmDiafora.Button39 then
begin
if Pos('FOREIGN KEY constraint failed', Msg)=1 then
begin
result := True; // to prevent system message
MessageBox('Αδύνατη η διαγραφή. Υπάρχουν συνδεόμενα.', 'Error', MB_OK+MB_ICONWARNING);
end;
end;
this function is if we get an error message FOREIGN KEY constraint failed', it should stop the procedure and giving us a custom message.
I want that when i press a button to get the result without running function. What I want is to create an option with the script running or without the script