[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

DBGrid Key Violation

Posted on 1997-04-18
2
Medium Priority
?
319 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

650 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