Strange Problem reading Firebird D/B

Hi All,

I have a windows app that needs to read data from Firebird D/B. The code is simple:

[code] rs = Old_DB.SQLSelect(“SELECT * FROM Customer”)
if rs <> nil then
While Not rs.EOF

  msgbox trim(rs.Field("Remarks").StringValue) + "?"

  rs.MoveNext
Wend

end if [/code]

The problem is some records returning the “Remarks” field is being truncated, and more even strange is the “?” can never be added to the string!

There seem no such problem for other fields of the same table like CustomerName.

This “Remarks” field is a text box entry (the program is written in Clarion), while CustomerName is a single line entry. However, both fields are declared in char, nothing special. Any idea?

Check and see if the remarks field contains chr(0) characters. That would cause the truncation you are seeing.

Also, you may want to define the encoding before passing it to msgbox based on what was put in.

If it’s Firebird >= v2.5 then you specify the encoding of your application’s strings (on connection) and the server transliterates between that and the encoding of the database.

But you still need to call DefineEncoding in your Xojo code in that case.

Yes, I am using firebird 2.5, the charset of the database is set to none, so the charset in the connection string in Xojo is set to none also. (coz it was using an old Clarion program which can only handles BIG5 characters).

[code] rs = Old_DB.SQLSelect(“SELECT * FROM Customer”)
if rs <> nil then
While Not rs.EOF

  myText = rs.Field("Remarks").StringValue.DefineEncoding(Encodings.xxxxxx)
 msgbox myText

  rs.MoveNext
Wend

end if
[/code]

I tried several encodings, but still doesn’t work. :frowning: Keep on trying…

I’d still like you to check the strings for chr(0) characters.

Hi Greg,

I retrieved a single record and check the ascii value of each single character, yes, there are a lot of chr(0) (represent null?) in the original data field. So, what should I do now?

Well as I said, it depends on the encoding. If you’ve got ascii, you can probably safely replace them with ReplaceAll. I’m not familiar with BIG5 and whether it translates to anything we have.