Hi
I am using an MSScript component, that I fill the SQL in dynamically.
Sometimes the SQL that gets filled in is with errors, like incorrect syntax near bla bla, or field not found or whatnots... BUT
MSScript.execute does NOT raise an exception, in stead it shows an error message to the user, with looks like a showmessage.
This is useless, as I cannot handle the error the correct way.
Am I correct in assuming that you showmessage and not raise an exception?
Best regards
Jens Fudge
MSScript not raising exception
-
AndreyZ
Hello,
Exceptions that can be raised during TMSScript execution are handled by the Application.HandleException method by default. To change such behaviour, you should use TMSScript.OnError event handler in the following way:In this case you will be able to handle exceptions on your own. For more information, please read the SDAC documentation.
Exceptions that can be raised during TMSScript execution are handled by the Application.HandleException method by default. To change such behaviour, you should use TMSScript.OnError event handler in the following way:
Code: Select all
procedure TMainForm.BitBtnClick(Sender: TObject);
begin
try
MSScript.SQL.Text := 'CREAET TABLE TEST(ID INT)';
MSScript.Execute;
except
ShowMessage('error');
end;
end;
procedure TMainForm.MSScriptError(Sender: TObject; E: Exception; SQL: String;
var Action: TErrorAction);
begin
Action := eaFail;
end;