#1 2012-03-09 13:53:25

profh
Member
Registered: 2010-07-02
Posts: 159

how to convert RawUTF8 to TSQLRawBlob?

i know how to use bintohex,but can not use hextobin to convert RawUTF8 to TSQLRawBlob.

any one any help?
thanks.

Offline

#2 2012-03-09 15:59:49

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,183
Website

Re: how to convert RawUTF8 to TSQLRawBlob?

What do you want to do exactly?

RawUTF8 is some UTF-8 encoded text
TSQLRawBlob is some blob of data - a RawByteString

Since RawByteString is a generic AnsiString, you can directly typecast TSQLRawBlob(aRawUTF8Var) if you really need to.
But be aware that you are starting to mix UTF-8 text and raw AnsiString: before Delphi 2009, there won't be any compiler warning so you may loose content.

Offline

#3 2012-03-10 01:46:45

profh
Member
Registered: 2010-07-02
Posts: 159

Re: how to convert RawUTF8 to TSQLRawBlob?

thanks,

What i exactly want to do is:
load/save binary data(TMemoryStream,not only Tsynpicture) from/into database.

i used bintohex and hextobin to convert between binary and RawUTF8, and then load/save  RawUTF8 from/into database,
sometimes i want to use TSQLRawBlob instead of RawUTF8...

Last edited by profh (2012-03-10 01:48:10)

Offline

#4 2012-03-10 21:16:17

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,183
Website

Re: how to convert RawUTF8 to TSQLRawBlob?

Read the documentation about TSQLRawBlob  fields: the framework is able to directly handle binary fields.
So it is not necessary to use RawUTF8 to exchange with the database.

Otherwise, TSQLRawBlob=RawByteString so it is directly usable with HexToBin.

Offline

Board footer

Powered by FluxBB