try
DataSource.DataSet.Post;
except
on E:EDBEngineError do
begin
if (E.ErrorCount > 0) and
(E.Errors[0].ErrorCode = DBIERR_KEYVIOL) then
MessageDlg('...', mtError, [mbOK], 0);
DataSource.DataSet.Cancel;
SysUtils.Abort;
end;
end;
The code is used within a called procedure. Everything works fine except
once the message has closed the program locks-up. This happens both within
the IDE and when running the EXE. We are using v5.1.1 of the BDE and Delphi
2 for this program.
Anyone have any idea why?
Ed Cuthbert
Why are you calling SysUtils.Abort? Normally, this is used in a method to
cancel the method operation, such as the OnNewRecord method of a table to
stop the insert action. It usually isn't needed in a called procedure. Since
you already use the Cancel method for the dataset, there shouldn't be
anything else to cancel using the Abort command. Don't know if this is your
problem, though.
Woody
I am using the SysUtils.Abort so the message "key violation" will not appear
after my message.
I tried eliminating it just to be sure. What happens is my message appears,
the "key violation" from the system appears and then the program locks. The
only way out is to Ctrl-Alt-Delete|End Task|End Task.
I also tried eliminating the DataSource.DataSet.Cancel and just using the
SysUtils.Abort. My message appears, then the program locks. The only way
out is, again, is CAD|ET|ET.
Thanks for trying. If you think of anything else, please feel free. This
has me stumped.
Ed
Ed,
I just tried something real quick to test a theory. The SysUtils.Abort
command raises an error. The only way to avoid seeing an extra error message
would be to wrap the Abort command in it's own little try.. except block
with nothing in the except part. Just let it do it's thing, catch the
exception and go on. Try this to see if it clears up your problem.
Woody
Thank you so much!! That worked perfectly. This has been a problem for a
while. If you don't believe me do a search on this News Group for
EDBEngineError.
In case anyone else may need it, the final code looks like:
try
DataSource.DataSet.Post;
except
on E:EDBEngineError do
begin
if (E.ErrorCount > 0) and
(E.Errors[0].ErrorCode = DBIERR_KEYVIOL) then
MessageDlg('...', mtError, [mbOK], 0);
DataSource.DataSet.Cancel;
try
SysUtils.Abort;
except
end;
end;
end;
Thanks again!
Ed
"woody" <wood...@ih2000.net> wrote in message news:39c1a25e$1_2@dnews...
Woody