LucieLastic
Programmer
hi
I'm reading a memo field from Sybase and would like to store it in a varchar field in SQLServer. I know that the field contains a hexadecimal number but they're stored as binary on the Sybase end. When I read this field in the field.datatype is ftBytes. How can I convert this hexadecimal number (stored as bytes) in to a string?
I have this so far (found on the web) but it is just returned #0 for each converted byte:
Grateful for any help on this one!
Cheers, guys
Lou
I'm reading a memo field from Sybase and would like to store it in a varchar field in SQLServer. I know that the field contains a hexadecimal number but they're stored as binary on the Sybase end. When I read this field in the field.datatype is ftBytes. How can I convert this hexadecimal number (stored as bytes) in to a string?
I have this so far (found on the web) but it is just returned #0 for each converted byte:
Code:
:
else if Field.DataType in [ftBytes, ftVarBytes] then
begin
result := VariantToString(field.value);
end
else
:
function TFormLoader.VariantToString(const vArray: variant): string;
var Cnt: integer;
function VarToString(const V: variant): string;
var Vt: integer;
begin
Vt := VarType(V);
case Vt of
{02}varSmallint,
{03}varInteger : result := Inttostr(integer(V));
{04}varSingle,
{05}varDouble,
{06}varCurrency : result := Floattostr(Double(V));
{07}varDate : ;//result := usgFormatDateTime(TDateTime(V));
{08}varOleStr : result := WideString(V);
{0B}varBoolean : ;//result := TF[Boolean(V)];
{0C}varVariant : result := VariantToString(Variant(V));
{11}varByte : result := char(byte(V)); //<---- This is the one which gets used
{100}varString : result := String(V);
{2000}varArray : result := VariantToString(Variant(V));
end; {case }
end;
begin
result := '';
if (vartype(vArray) and VarArray)=0
then result := VarToString(vArray)
else for Cnt := VarArrayLowBound(vArray, 1) to
VarArrayHighBound(vArray, 1) do
result := result+VarToString(vArray[Cnt]);
end;
Grateful for any help on this one!
Cheers, guys
Lou