Question

I have a Delphi 7 app using Paradox database via BDE, that I have converted to Delphi XE3 and Firebird. There is a string field in the Paradox database containing an encrypted string that is supposedly used for licensing of the software. The problem is that while a routine that read this string in the old program (D7/Paradox) worked fine, in the new program (XE3/Firebird) the routine is throwing an error. The cause I have found through debugging is that the string after being read from the database is different. How can I fix this?

The string in the old Paradox database:

Ng-DrLrDOtfâtD89D1'D'îu

The string in the new Firebird database:

Ng-DrLrDOtfâtD89D1'D'îu

As you can see above the string is the same in both databases.

In the new Delphi XE3 program, using UniDAC data access components when I try to get the value of the field using FieldByName('fieldname').AsString , this is what is returned:

Ng-DrLrDOtfâtD89D1'D'îu

You can see that a couple of characters are different. This is causing an error in the routine that is checking this string in program. Did you experience this before? What are the possible causes of this problem and what steps can I take to resolve this.

Note 1: I converted the Paradox database to Firebird with a converter that I wrote in Delphi (For the actual code for this converter, see: http://goo.gl/6xu2ST)

Note 2: I have the database created with DEFAULT CHARACTER SET UTF8 and the UniDAC connection component (TUniConnection) has got SpecificOptions CharSet set to 'UTF8'.

Was it helpful?

Solution

I solved the problem by:

  1. In the data-module or code, set the TUniConnection component property SpecificOptions UseUnicode to True.

  2. Close the project and the Delphi IDE. Open WinGrep and do a Find-Replace in all the project PAS and DFM files for the string: TStringField, changing it to TWideStringField.

  3. Re-compile.

And voila, its working perfect! Errors caused at runtime due to incomplete translation/interpretation of Unicode characters from database has gone away.

Thank you everyone who responded earlier.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top