Dear all, I am currently at an utter loss. There isnt a single tutorial i read online that covers raising a ValidationError on encountering a duplicate key value in a CRUD application.
Basically, I have a data entry form on which on clicking the OK button will insert a record in the database. That table has enforced a primary key constraint on one of the columns. On inserting a record with a duplicate PK value, I have written code in the catch block of the method that does the record insertion. On analyzing the error code, I am able to trap the exception raised.
Two questions though:
How do i write code that actually raises a ValidationError and visually prompt the user like shading the textbox some color or something?
How do i know exactly which field has raised the error? Trapping SQLErrors and checking the error code only reveals the fact that an error has occurred but it doesnt exactly tell you which field has caused the error.
Thank you very much. Really appreciate any pointers or any tutorials that cover this.
Db used is db2.