Subject | How can I write binary bytes on CHAR(20) field? |
---|---|
Author | semprelliure |
Post date | 2003-08-07T10:59:45Z |
Hi everybody.
I have problems writing sequences of arbitrary bytes (including
binary zero) in CHAR()/VARCHAR() CHARACTER SET OCTETS field.
Which TIB_Colum method must I use?
I'm trying with AsString, AsRawString, ColData, even SetBlobData(),
and I can't get my string char (with #0 byte in the middle) be
assigned. The value always is truncated at the #0 byte position.
I'm working with WinXP, Firebird 1.0, IBO 4.2Hi, C++Builder5.
My code is something like this:
char my_string[10];
memset(my_string,0,10);
*(my_string+0)=65; // 'A'
*(my_string+1)=66; // 'B'
*(my_string+2)=0; // this breaks all :(
*(my_string+3)=67; // 'C'
*(my_string+4)=68; // 'D'
IB_Query1->FieldByName("MY_COMMAND")->AsString=my_string;
or
IB_Query1->FieldByName("MY_COMMAND")->AsRawString=my_string;
or
IB_Query1->FieldByName("MY_COMMAND")->SetBlobData(my_string,5);
Always assign "AB", and the rest of the string is lost.
There is not an AsBinary method?
Which is the right way? Some sample will be appreciated, even in
Delphi.
Many thanks in advance.
Hugo
I have problems writing sequences of arbitrary bytes (including
binary zero) in CHAR()/VARCHAR() CHARACTER SET OCTETS field.
Which TIB_Colum method must I use?
I'm trying with AsString, AsRawString, ColData, even SetBlobData(),
and I can't get my string char (with #0 byte in the middle) be
assigned. The value always is truncated at the #0 byte position.
I'm working with WinXP, Firebird 1.0, IBO 4.2Hi, C++Builder5.
My code is something like this:
char my_string[10];
memset(my_string,0,10);
*(my_string+0)=65; // 'A'
*(my_string+1)=66; // 'B'
*(my_string+2)=0; // this breaks all :(
*(my_string+3)=67; // 'C'
*(my_string+4)=68; // 'D'
IB_Query1->FieldByName("MY_COMMAND")->AsString=my_string;
or
IB_Query1->FieldByName("MY_COMMAND")->AsRawString=my_string;
or
IB_Query1->FieldByName("MY_COMMAND")->SetBlobData(my_string,5);
Always assign "AB", and the rest of the string is lost.
There is not an AsBinary method?
Which is the right way? Some sample will be appreciated, even in
Delphi.
Many thanks in advance.
Hugo