Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

EDBEngineError - Program Hangs After Using in Delphi 2

28 views
Skip to first unread message

Ed Cuthbert

unread,
Sep 13, 2000, 3:00:00 AM9/13/00
to
We have a program we are using the following code to trap and customize an
error message when a "key violation" is found.

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

woody

unread,
Sep 14, 2000, 3:00:00 AM9/14/00
to
"Ed Cuthbert" <cuth...@ionia-mi.net> wrote in message
news:39c018b4_1@dnews...

> We have a program we are using the following code to trap and customize an
> error message when a "key violation" is found.
>
> 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;
>
>

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

Ed Cuthbert

unread,
Sep 14, 2000, 3:00:00 AM9/14/00
to
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

woody

unread,
Sep 14, 2000, 3:00:00 AM9/14/00
to
"Ed Cuthbert" <cuth...@ionia-mi.net> wrote in message
news:39c0eddc_2@dnews...

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

Ed Cuthbert

unread,
Sep 15, 2000, 3:00:00 AM9/15/00
to
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

unread,
Sep 15, 2000, 3:00:00 AM9/15/00
to
Glad to help. One note to newbies reading this thread, though, using an
empty try..except block defeats the purpose of meaningful error catching. In
this particular case, we know that the error is only an abort message so
it's (somewhat) OK to do it. However, it should not become a way to solve
all error problems.

Woody

0 new messages