[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

DBGrid Key Violation

Posted on 1997-04-18
2
Medium Priority
?
322 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 300 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month18 days, 23 hours left to enroll

834 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