Catch the event after user clicked "cancel" during connect

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
easyblue
Posts: 64
Joined: Wed 02 Feb 2005 13:02
Location: Shanghai

Catch the event after user clicked "cancel" during connect

Post by easyblue » Fri 26 Jun 2009 07:19

Hello

Using an TOraSession and TConnDialog, when starts connecting, a dialog will pop up.

The question is what happened after user clicked "cancel".

For current ODAC, it will have an Abort operation, and return to windows, and user can not catch such event.

Such event is necessary in such a case:

In a thread, some resource is prepared before user starts to make connect, and when user canceled connection, or connection failed, system catches the event and make neccessary resource free and warning.

[suggestion solution]
1. Introduce a "ConnectResult", such as:
...
OraSession.Connect;
case ConnectResult of
crSucce:
crUserCancel:
crFailed:
....

2. change Connect Method into Dialog-like
...
if OraSession.Connect
begin
end
else
begin
end

3. Add OnCancel, OnOK event to TConnDialog

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Fri 26 Jun 2009 08:49

You can use try..except operator to catch the connection cancelling:

Code: Select all

try
  OraSession.Connect;
except
  on EAbort do
    ...
end;

Post Reply