Board index » delphi » DB Error messages - How to translate them?

DB Error messages - How to translate them?

Hi,

Is there the possibility to translate the error messages that comes from the
database?

I used this code :

procedure TDataModule03010.dspLogUpdateError(Sender: TObject;
  DataSet: TCustomClientDataSet; E: EUpdateError; UpdateKind: TUpdateKind;
  var Response: TResolverResponse);
begin
  inherited;
  MessageDlg(Format('Context: %s; Message: %s, Code: %d', [e.Context,
e.Message, e.ErrorCode]), mtInformation, [mbOk], 0);
end;

The problem is that when using dbXpress, e.error code is always 1 and it
doesn't specify the error type occurred (key violation, record not found,
etc.) so I can't intercept it and display my message.
The e.Message is in english and I would like to receive them in Italian to
display it to the user.

Is there a chance?

Thanks
Antonio Budano

 

Re:DB Error messages - How to translate them?


"Antonio Budano" <anto...@altairnet.com> schrieb im Newsbeitrag
news:3c18742d_2@dnews...
Quote
> Hi,

> Is there the possibility to translate the error messages that comes from
the
> database?

> I used this code :

> procedure TDataModule03010.dspLogUpdateError(Sender: TObject;
>   DataSet: TCustomClientDataSet; E: EUpdateError; UpdateKind: TUpdateKind;
>   var Response: TResolverResponse);
> begin
>   inherited;
>   MessageDlg(Format('Context: %s; Message: %s, Code: %d', [e.Context,
> e.Message, e.ErrorCode]), mtInformation, [mbOk], 0);
> end;

> The problem is that when using dbXpress, e.error code is always 1 and it
> doesn't specify the error type occurred (key violation, record not found,
> etc.) so I can't intercept it and display my message.
> The e.Message is in english and I would like to receive them in Italian to
> display it to the user.

> Is there a chance?

> Thanks
> Antonio Budano

are You working with oracle?
You could parse the message -string for an 'ORA-' occurence
then extract the following ErrNumber (always 5 digits).

if ErrNumber = 1 then MyMessage:='Oracle Unique key Error'
...

Michael K.

Re:DB Error messages - How to translate them?


Quote
> are You working with oracle?
> You could parse the message -string for an 'ORA-' occurence
> then extract the following ErrNumber (always 5 digits).

> if ErrNumber = 1 then MyMessage:='Oracle Unique key Error'
> ...

> Michael K.

No Michael,

I'm working with Interbase.

I choose to use DBXpress to access Interbase in order to have the
possibility in the future to change DB easily.

If I will use the approach you suggest, if there will be some equivalent for
Interbase, I will need to change this part of code when I will change the
DB.

I don't believe that there isn't the possibility to check some "standard"
return code, independent from the DB.

It should be something that the driver returns to DBX.

Thanks

Antonio Budano

Re:DB Error messages - How to translate them?


i hope this will help you.

- open a blank project
- project/addtoproject  c:\prog.files\borland\delphi\source\Vcl\consnts.pas
- project/addtoproject  c:\prog.files\borland\delphi\source\Vcl\dbconsts.pas
- project/addtoproject
c:\prog.files\borland\delphi\source\Rtl\sysconsts.pas

look for the errors messages in 3 pas files , if you find which you are
looking for , change them with your language,if not do same process for
another pas files (in VCL)
then save this project and pas files (with same name) to any directory (for
example c:\test )
then run the blank project (to make dcu files ) then copy to these new dcu
files(in c:\test)(consts.dcu,sysconsts.dcu...) in to
c:\prog.files\borland\delphi\lib
close delphi , and run delphi again.

i use this method to change button names in messagedlg , inputquery..
 Ok,Cancel,Help,Yes,No..........)
and wrong date error,printer errors,dberrors...

Other Threads