Delphi 2007 DBX Auto-Trim CHARS

I'm working on converting a program from Delphi 6 + BDE to Delphi 2007 + DBX and using Sybase in both cases. One of the problems I'm running into is that BDE would remove any trailing white space from CHAR fields but DBX leaves trailing whitespace. Is there a way to have sybase or DBX remove any trailing whitespace?
Who is Participating?
jimyXConnect With a Mentor Commented:
Normally when Char values are retrieved, trailing spaces are removed. If this is not your case try to Trim the column, it could be an actual spaces.

>   "I'm looking for either a driver setting or a database setting that with automatically remove trailing white space from CHAR fields."

I am not sure but I doubt if there is such setting because it's clearly set by the datatypes.
I am not sure if this helps but you can try:
gregatcxnAuthor Commented:
The problem I'm having is with CHAR columns. For instance a CHAR (4) field with the value 'sa' will give 'sa  ' when selected. I'm looking for a way to remove the trailing spaces.
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

That's called blank padding and it is a feature in the Char Datatype. If you do not want that then use VarChar instead.

I have had same issue but different scenario/case with the blank character. BTW, it is not a space that is used to complete the length of the field it's a blank character which is used as complementary character so at the end the field meets the size indicated at the creation:

Field Name: UserName
Data Type  : Char(12)

UserName='gregatcxn' it will be stored 'gregatcxn   ' where the last blanks are not spaces. If you tried to trim them as spaces you will not be able to.

I have an example to distinguish between the blank character and the space.
Can you match between the gaps among the #'s in the attached Excel sheet by going to Edit menu in the MS Excel and click Replace and then in "Find what:" put a space from your keyboard and in "Replace with:" put the dollar sign "$".
gregatcxnAuthor Commented:
Unfortunately the database is deployed at client sites and the DBA's will not change CHARs to VARCHARs for performance reasons.

When querying Sybase with DBX, the blanks at the end of the field are spaces and can be removed with a trim. Turning the 'blanks' into spaces is probably something the DBX drivers do automatically.

I'm looking for either a driver setting or a database setting that with automatically remove trailing white space from CHAR fields.

This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.