Link to home
Start Free TrialLog in
Avatar of andrewjb
andrewjbFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Another simple ADO query question..

I use an ADO query ( insert into ...) to add a record to a table, and execute using qry->ExecSQL()

If there's an index violation (duplicate key / illegal empty field etc) it throws an exception. Can't I trap that somehow? The query component has OnPostError and OnEditError but they don't get called? Or do I have to try to insert the record a different way?

ASKER CERTIFIED SOLUTION
Avatar of esoftbg
esoftbg
Flag of Bulgaria image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of andrewjb

ASKER

I've realised after posting that I can, of course, just try...catch around the ExecSQL. That works, but do you have an opinion as to the 'best' way to do it? Which one would trigger the OnPostError etc. events?

It really does not work:
ADOQuery1PostError();
I tryed to debug it, posted an illegal data for a field, but an exception raises and the debuger does not go into the OnPostError ?
I don't know why ....
SOLUTION
Avatar of kretzschmar
kretzschmar
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial