Dear all, I'm presently in an utter loss. There is not just one tutorial i just read online that covers raising a ValidationError on experiencing a replica key value inside a CRUD application.

Essentially, I've got a data entry form which on clicking the OK button will place an archive within the database. That table has enforced a principal key constraint on among the posts. On placing an archive having a duplicate PK value, I've written code within the catch block from the method that does the record insertion. On examining the mistake code, I can trap the exception elevated.

Two questions though:

  1. How do you write code that really boosts a ValidationError and aesthetically prompt the consumer like shading the textbox some color or something like that?

  2. How do you know precisely which area has elevated the mistake? Trapping SQLErrors and checking the mistake code only discloses the truth that a mistake has happened however it does not exactly let you know which area has triggered the mistake.

Thanks greatly. Really appreciate any pointers or any lessons which cover this.

Db used is db2.

What about this?

http://joshsmithonwpf.wordpress.com/2008/11/14/using-a-viewmodel-to-provide-meaningful-validation-error-messages/

This tutorial should answer your question #1.

For the question #2, I am unsure I realize how placing an archive having a duplicate area could be associated with any particular data entry area. Actually, should not your database be setting and incrementing the main key value instantly? This could eliminate the potential of a replica key entirely.