Pages

Addressing failed connection with ADOConnection


 Herea few tips to catch an exception when it fails to connect with ADOConnection.

1. Add the ComObj library inside uses on the code.

unit Unit1;

interface

uses

ComObj, Windows, Messages, SysUtils, Variants, Classes,

Graphics, Controls, Forms, Dialogs;

type

TForm1 = class(TForm)

private

...

2. When connecting with ADOConnection add the following script.

with ADOConnection1 do
Try
Connected := True;
except
on EOleException do
begin
MessageDlg('Koneksi gagal, silahkan anda ulangi sekali lagi',MtInformation,[mbOK],0);
end;
end;

Note: if you do not add the ComObj library in uses, then the EOleException exception will not be invoked.

Hopefuly the article is helpful.

Similiar with here

0 comments:

Post a Comment