Solved

DBGrid Key Violation

Posted on 1997-04-18
2
306 Views
Last Modified: 2010-04-04
When editing a DBGrid and entering a duplicate value into a unique key field a 'Key Violation' error occurs. Is there anyway of trapping this error to provide a more user friendly message?
0
Comment
Question by:roblan
2 Comments
 
LVL 2

Accepted Solution

by:
javiertb earned 100 total points
ID: 1335458
You could trap the error by means of OnPostError table event. There you can chose what to do and the database error you got.

Hope this helps.
0
 

Expert Comment

by:jmstolting
ID: 1335459
..or handle the EKeyViolation exception directly :

 try
   TheTable.post;
 except
   MessageDlg('This key already exists!',mtWarning,[mbOk,0);
   TheTable.cancel; // remove the record
 end;
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now