Board index » delphi » String data field in database

String data field in database

I have one paradox table that contains on field named STATUS (Edit
alpha, length 1). When I execute the following code :

var ch : char

ch := MyTable.FieldByName('STATUS').AsString[1];

If STATUS has some value diferent than space, it works OK, but if it
contains space, ch returns '8'     ?????

What should I do ??    thanks in advance

Marcio.

 

Re:String data field in database


Quote
Marcio Kennedy Yatsuda wrote:

> I have one paradox table that contains on field named STATUS (Edit
> alpha, length 1). When I execute the following code :

> var ch : char

> ch := MyTable.FieldByName('STATUS').AsString[1];

> If STATUS has some value diferent than space, it works OK, but if it
> contains space, ch returns '8'     ?????

> What should I do ??    thanks in advance

> Marcio.

Paradox will not store spaces at the end of alpha fields - it makes
searching a real pain in the backside.  After all, >Mark< LOOKS the same
as >Mark   <, but is quite different.  I tried your example, and if you
take a look at the field value in Database Desktop, you will see that
the space is not stored, and the field's value is Null.

I think you should add some code to test for IsNull on the field, and
rework whatever algorithm you have which relies on a space...or use an
underscore.

Other Threads