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
Solved

DBGrid Key Violation

Posted on 1997-04-18
2
308 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

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 video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

809 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