Subject | Re: [IBO] catching excpetion in TIB_Connection.Connect |
---|---|
Author | Helen Borrie |
Post date | 2002-09-25T05:15:57Z |
At 03:58 AM 25-09-02 +0000, you wrote:
default "re-try login" handling is going to reiterate three times before it
passes control over to the OnLoginFailure event. Set your LoginAttempts
back to 1 and read the error status array in the OnError event...though I
would expect OnError to pick up the appropriate EIB_ISCError each time
login fails...
Does this help to answer your questions about when and where the exceptions
occur?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IB_Components, IB_Header;
type
TForm1 = class(TForm)
IB_Connection1: TIB_Connection;
procedure IB_Connection1Error(Sender: TObject; const ERRCODE: Integer;
ErrorMessage, ErrorCodes: TStringList; const SQLCODE: Integer;
SQLMessage, SQL: TStringList; var RaiseException: Boolean);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.IB_Connection1Error(Sender: TObject;
const ERRCODE: Integer; ErrorMessage, ErrorCodes: TStringList;
const SQLCODE: Integer; SQLMessage, SQL: TStringList;
var RaiseException: Boolean);
begin
if ERRCODE = isc_io_error then
Showmessage('Database file not found');
Abort;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
inherited;
try
if not ib_connection1.Connected then
ib_connection1.Connect;
except
ShowMessage('Constructing database...please wait.');
end;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
if not ib_connection1.Connected then
Close;
end;
end.
Helen
>Hi Steve,Is it possible you have LoginAttempts set to the default of 3? If so, the
>
>My problem is that when I have either type of login (default, or my
>own) I cannot handle the exception.
>In the onCreate event of my dataModule, I have the following code:
>
>try
>myConn.Connect;
>except on e: EIB_ISCError do begin
>//(pseudo-code) if e.error = file_not_found
> createDB();
>end;
>end;
>
>When I have loginPrompt=False, and the file is not found, createDB()
>is called, but when I have LoginPrompt=True, createDB is NOT called,
>as the exception is hadled elsewhere.
>What I would like to know is where this exception is handled, and
>why doesn't my exception block catch it.
default "re-try login" handling is going to reiterate three times before it
passes control over to the OnLoginFailure event. Set your LoginAttempts
back to 1 and read the error status array in the OnError event...though I
would expect OnError to pick up the appropriate EIB_ISCError each time
login fails...
Does this help to answer your questions about when and where the exceptions
occur?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IB_Components, IB_Header;
type
TForm1 = class(TForm)
IB_Connection1: TIB_Connection;
procedure IB_Connection1Error(Sender: TObject; const ERRCODE: Integer;
ErrorMessage, ErrorCodes: TStringList; const SQLCODE: Integer;
SQLMessage, SQL: TStringList; var RaiseException: Boolean);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.IB_Connection1Error(Sender: TObject;
const ERRCODE: Integer; ErrorMessage, ErrorCodes: TStringList;
const SQLCODE: Integer; SQLMessage, SQL: TStringList;
var RaiseException: Boolean);
begin
if ERRCODE = isc_io_error then
Showmessage('Database file not found');
Abort;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
inherited;
try
if not ib_connection1.Connected then
ib_connection1.Connect;
except
ShowMessage('Constructing database...please wait.');
end;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
if not ib_connection1.Connected then
Close;
end;
end.
Helen