EvgeniyM wrote:Use TCustomClientDataSet.OnReconcileError event handler to handle any update error.
TSQLQuery doesn't have this event.
I think I didn't explain clearly enough what I was lookign for. OnReconcile Error handles the errors only that are are described in the held like this:
Delphi-Help wrote:Write an OnReconcileError event handler to respond to error conditions that arise when the Reconcile method cycles through records that could not be applied to the database. This event handles only those update errors that were not handled in an OnUpdateError event handler.
What I am looking for is the real SQL server Msg Number when an error occurs. Trying to use this SQL statement e.g., an violoation to a unique key constraint might occur, and the SQL Query Analyzer gives me the following:
Code: Select all
insert into personen (Name) values ('Test')
Code: Select all
Server: Msg 2627, Level 14, State 1, Line 1
Violation of UNIQUE KEY constraint 'IX_Personen'. Cannot insert duplicate key in object 'dbo.personen'.
The statement has been terminated.
I have to catch this server error N° 2627.
How can I do this?