Capture Post errors
It is a question that I have already answered it some that another time, so I will write it in this trick for not answering it more.
When we use DataAware controls such as DBNavigator or DBGrid, and they can add registers it is possible that the user introduces two registers with the same key field, being generated an exception therefore.
How can we capture this exception?, since the Post is made for the corresponding database control (DBGrid, etc)
So... it's very easy, the errors generated making the Post in a table, are centralized in the OnPostError event of the TTable... we will only have to use it.
For example, using a similar code to this:
With the parameter Action, we can specify that it is what it is necessary to make with the Post that it generated the error.
In the example, we use daAbort to abort the Post.