--> Error Handler for Error Duplicates Inserting Data on Delphi with Microsoft Access Database | Delphi Tips Trick

For Newbie

Tuesday 27 September 2011

Error Handler for Error Duplicates Inserting Data on Delphi with Microsoft Access Database

| Tuesday 27 September 2011


Error Handler for Error Duplicates Inserting Data on Delphi with Microsoft Access Database
Big possibilities of a lot of beginners in database programming using Delphi, ever been found an error message like this:

“Project raised exception class EOleException with message 'The Change you requested to the table were not successful because they would create value in the index, primary key, or relationship. Change the tata in the fields that contain duplicate data, reove the index, or redefine the index to permit duplicate entries and try again'. Process stopped. Use Step or Run to Continue”

This message appear when there is mistake like duplication (double data) in a filed that is set as unique field, usually marked with primary key. The field does not allow identical data to be inserted into record on that field.
In this article, there is example where the insert processing database conducted through  ADOTable component, the error message that appear is as follows:


The solution to solve the error duplicate database problem is as follows:


Add the following source code on event OnPostError properties that Adotable component :



var
Action: TDataAction);// àà this source code to abort the inserting data process
begin
Action:=daAbort;
ShowMessage('Error Duplicate data, Double Counting');
end;


 So when duplication happen when adding new data, will appear message like the following and that data will not be saved, or abort.




  I hope this writing can give benefit to the visitors, readers, developer and me. Thanks for visiting and availability for sharing this article by pressing 
Share this on Facebook
or just press like button under this posting

Related Posts