Icon View Thread

The following is the text of the current message along with any replies.
Messages 11 to 12 of 12 total
Thread Blobs
Mon, Mar 14 2011 4:52 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim

> SetLength(TempString,(Length(DoubleArray)*SizeOf(Double)));
> Move(DoubleArray[0],TempString[1],Length(TempString));

Neat way to convert to a string - I'll add to my toolbox.

Does using .AsBlob mean you don't have to use BinaryToSQLStr?

Roy Lambert

Mon, Mar 14 2011 9:09 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< Does using .AsBlob mean you don't have to use BinaryToSQLStr? >>

AsBlob basically is just an AnsiString property in the older versions of
Delphi so yes, you should not use BinaryToSQLStr because the TParam actually
wants a straight-up buffer, not a hex-encoded string.  There's a lot of this
"string abuse" in the earlier days of Delphi where byte arrays weren't used
as much.  Now that byte arrays are more prevalent, the AsBlob property in
the newer versions of Delphi use byte arrays (TBytes).

Which basically brings me to my next statement:  David, I gave you the
information for older versions of Delphi, not Delphi XE.  With Delphi XE,
you can use this:

var
  DoubleArray: array of Double;
  TempBytes: TBytes;
begin
  SetLength(DoubleArray,10);
  DoubleArray[0]:=100;
  DoubleArray[9]:=200;
  SetLength(TempBytes,(Length(DoubleArray)*SizeOf(Double)));
  Move(DoubleArray[0],TempBytes[0],Length(TempBytes));
  with EDBQuery1 do
     begin
     SQL.Text:='insert into david (ID, DATA) values (:ID, :DATA)';
     Prepare;
     ParamByName('ID').ParamType:=ptInputOutput;
     ParamByName('DATA').AsBlob:=TempBytes;
     ExecSQL;
     end;
end;

--
Tim Young
Elevate Software
www.elevatesoft.com
« Previous PagePage 2 of 2
Jump to Page:  1 2
Image