Recent

Author Topic: Getting Firebird database error codes  (Read 4654 times)

talorigomat

  • Jr. Member
  • **
  • Posts: 96
Getting Firebird database error codes
« on: February 26, 2015, 07:57:14 pm »
I'm using the SQLdb component (TIBConnection) to access a firebird database.  Is there a way of getting the error code which Firebird generates error?  I already know how to get the error message with

Code: [Select]
try
  [i]code which my produce error[/i]
  .......

except
  on E: EDatabaseError do
    ShowMessage(E.Message);
end;

Lazarus 1.8.0Rc4, Windows 10

LacaK

  • Hero Member
  • *****
  • Posts: 691
Re: Getting Firebird database error codes
« Reply #1 on: February 26, 2015, 09:04:12 pm »
try
  code which my produce error
  .......

except
  on E: EIBDatabaseError do
    ShowMessageFmt('ErrorCode: %d; Messsge: %s', [E.GDSErrorCode, E.Message]);
end;

or better:

try
  code which my produce error
  .......

except
  on E: ESQLDatabaseError do
    ShowMessageFmt('ErrorCode: %d; Messsge: %s', [E.ErrorCode, E.Message]);
end;

talorigomat

  • Jr. Member
  • **
  • Posts: 96
Re: Getting Firebird database error codes
« Reply #2 on: February 26, 2015, 09:29:17 pm »
Hi LacaK

 Thanks for helping with this.  With both examples you gave I received the following error when compiling:

Error: identifier idents no member "GDSErrorCode"


Lazarus 1.8.0Rc4, Windows 10

LacaK

  • Hero Member
  • *****
  • Posts: 691
Re: Getting Firebird database error codes
« Reply #3 on: February 27, 2015, 06:16:55 am »
Interesting? For me it compiles successfully. May be, that you use some older version of FPC than me ? (I use TRUNK)

talorigomat

  • Jr. Member
  • **
  • Posts: 96
Re: Getting Firebird database error codes
« Reply #4 on: February 27, 2015, 06:54:24 am »
I'm using Lazarus 1.4 RC1 which was released recently.
Lazarus 1.8.0Rc4, Windows 10

LacaK

  • Hero Member
  • *****
  • Posts: 691
Re: Getting Firebird database error codes
« Reply #5 on: February 27, 2015, 09:25:10 am »
 EIBDatabaseError must have GDSErrorCode member ... check again your program
(do not mix ESQLDatabaseError with EIBDatabaseError)

talorigomat

  • Jr. Member
  • **
  • Posts: 96
[Solved]: Getting Firebird database error codes
« Reply #6 on: March 02, 2015, 01:51:17 am »
Thanks LacaK.  Silly me.  I had not changed the "on E: EDatabaseError do"  part of the my code.

Many thanks for the help.

Just to add I got it to work using :

Code: [Select]
except
  on E: EIBDatabaseError do

but not with:

except
  on E: ESQLDatabaseError do
    ShowMessageFmt('ErrorCode: %d; Messsge: %s', [E.ErrorCode, E.Message]);

with the latter I get:
unit1.pas(89,15) Error: Identifier not found "ESQLDatabaseError"
unit1.pas(89,33) Error: class type expected, but got "<erroneous type>"
« Last Edit: March 02, 2015, 02:56:23 am by talorigomat »
Lazarus 1.8.0Rc4, Windows 10

LacaK

  • Hero Member
  • *****
  • Posts: 691
Re: [Solved]: Getting Firebird database error codes
« Reply #7 on: March 02, 2015, 08:17:59 am »
but not with:

except
  on E: ESQLDatabaseError do
    ShowMessageFmt('ErrorCode: %d; Messsge: %s', [E.ErrorCode, E.Message]);

with the latter I get:
unit1.pas(89,15) Error: Identifier not found "ESQLDatabaseError"
unit1.pas(89,33) Error: class type expected, but got "<erroneous type>"

May be, that ESQLDatabaseError was not backported to FPC 2.6.4
But with next release of FPC 3.0.0 it will work  :)

 

TinyPortal © 2005-2018