MySql long strings to a string

TomDuncan

Active Member
Licensed User
Longtime User
Hi,
I have a database which has text fields which are long.
Using GetString it comes up with an error saying it could not convert blob fields into text.

I then tried this

Sub ReadBlobString(tbl As String,Rec As String, code As String) As String
Dim Cursor1 As Cursor
Dim A,S As String

S= "SELECT "&Rec&" FROM "&tbl&" WHERE Pcode = " & QUOTE & code & QUOTE
Cursor1 = SQL1.ExecQuery(S)
Cursor1.Position = 0
Dim Buffer() As Byte 'declare an empty byte array
Buffer = Cursor1.GetBlob(Rec)
Dim i As Int
A= CharsToString( Chr(Buffer(i)), 0, Buffer.Length)

Return A

End Sub

But it says I cannot cast the Char.
Any ideas anyone. These fields are text only but with CR & LF I think.

Tom
:sign0104:
 

stevel05

Expert
Licensed User
Longtime User
Just a guess, as I cant try it, and you don't say where the error occurs but you are using CharToString on a bytes array, Try BytesToString.

And your syntax isn't quite right either, these routines will convert an array in one go, so don't need indexing and in the case of CharToString, wouldn't need to convert with Chr().

If this doesn't help please post some more info/error message and related line nos.

Steve
 
Upvote 0

TomDuncan

Active Member
Licensed User
Longtime User
Thanks Steve.
This works like a charm..
A=BytesToString(Buffer,0,Buffer.Length,"UTF-8")

:sign0142:

I am sure I will need to post more problems.
New to Android, still love Delphi 7

Tom
 
Upvote 0
Top