EPgError

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for PostgreSQL in Delphi and C++Builder
Post Reply
p.boutin
Posts: 6
Joined: Mon 09 Aug 2010 14:29

EPgError

Post by p.boutin » Mon 09 Aug 2010 14:33

Hi there,

I would like to catch EPgError but I can't find which unit I have to add into the uses.

I bought a licence wilthout the source code. Is this possible ?
Otherwise how can I treat the EPgError ?

Thank by advance, Paul

ps: I'm programing with delphi 6

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Tue 10 Aug 2010 12:17

Hello.

To use EPgError Exception it's necessary to add the PgError unit to uses section.

p.boutin
Posts: 6
Joined: Mon 09 Aug 2010 14:29

Post by p.boutin » Tue 10 Aug 2010 15:37

Thank you alex

but unfortunatly I do not have the pgError.pas or pgError.dcu file.
Where is this located ?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Wed 11 Aug 2010 08:35

Hello.

The default path to PgError.dcu is (your system drive):\Program Files\Devart\PgDac for Delphi 6\Lib, if you install PgDac in another dir, search PgError.dcu in (your instal pgDac directory)/lib

Please check if path to the PgDAC library is available in
delphi->tools->Environment Options->Library->Library Path
....;:\Program Files\Devart\PgDac for Delphi 6\Lib;:\Program Files\Devart\PgDac for Delphi 6\Bin

if this path doesn't exist it is necessary to reinstall PgDAC or add this path manually

p.boutin
Posts: 6
Joined: Mon 09 Aug 2010 14:29

Post by p.boutin » Wed 11 Aug 2010 09:29

Thank again alex for your prompt reply

We bougth "dbExpress Driver for PostgreSQL" not the "Delphi data access components".

In delphi->tools->Environment Options->Library->Library Path,
I added "C:\Program Files\DBxPgSQL\Source"

It contains

CRDbxDesign.pas
CRSQLConnection.pas
DBXDevartPostgreSQL.pas
DriverOptions.pas

but I can't find the PgError.dcu file into my Devart\DbxPgSQL directory.

So I installed the pgDAC trial version just to be able to put pgError in my uses. This worked.

Code: Select all

  
try
   SQLConnectionWithWrongSettings.connected := True
except
    on E: EPgError do
       ShowMessage('It is EPgError: ' + E.ErrorCode + ' - ' + E.Message);
    on E: EDAError do
       ShowMessage('It is EDAError: ' + IntToStr(E.ErrorCode) + ' - ' + E.Message);
    on E: EDatabaseError do
       ShowMessage('It is EDatabaseError: ' + E.Message);
    on E: Exception do
       ShowMessage(E.Message);
end;
With this code when I run the program through Delphi, the IDE raises 3 exceptions
1- EpgError : Database does not exists
2- EpgError : Database does not exists
3- EDatabaseError : Database does not exists

then the debugger go into the except section and show the message

Code: Select all

'It is EDatabaseError: ' + E.Message'
How can I catch the EPgError in order tobe able to retrieve the ErrorCode ?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Wed 11 Aug 2010 14:40

Hello,

We have performed a detailed investigation of the problem. To catch the dbExpress exception you can use
the TDBXError class (it is necessary to add the DBXCommon unit in uses), because in dbExpreess EPgError is replaced by TDBXError

p.boutin
Posts: 6
Joined: Mon 09 Aug 2010 14:29

Post by p.boutin » Thu 12 Aug 2010 07:46

Hi Alex,

Which release of Delphi were you using while investigating the problem ?

I use delphi 6 which include an old release of DBXpress.
I do not have the DBXcommon the only units I have are

DBXpress,
DBXpressWeb

Update the DBXpress components does not seems a safe way for us. (I'm not even sure that this is possible, these components are installed with delphi..)

What do you suggest ?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Thu 12 Aug 2010 09:34

Hello,

You are right, the DBXCommon unit is available starting from Delphi 2007.
In earlier Delphi versions you can use EDatabaseError.

p.boutin
Posts: 6
Joined: Mon 09 Aug 2010 14:29

Post by p.boutin » Thu 12 Aug 2010 12:25

OK... That's what I'm currently doing but there is no error code in this type of exception so I'm not able to manage errors properly because I can't identify errors with a single message Exception property..

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Fri 13 Aug 2010 08:26

Hello,

You can't get ErrorCode, because dbExpress work through standard Delphi database classes that don't support the ErrorCode property.

p.boutin
Posts: 6
Joined: Mon 09 Aug 2010 14:29

Post by p.boutin » Mon 16 Aug 2010 12:13

At list I know that I can't retreive it.

Thank you for your help Alex

Post Reply