Inserting a Graphic(BLOB) in a MSSQL Server 2000 table
Hi,
I have tried with the following code but I get always an error (Invalid Blob
Length) when I post the new inserted record. When I try the same with
Paradox, it works fine.
Does anyone know where the problem is? Or is there other solutions (with
TQuery? for the time being I prefer to still use BDE but if a simple ADO
solution exists, why not?)
Thanks a lot and best regards,
Hubert Rtif.
var
imgBStream: TBlobStream;
imgFStream: TFileStream;
begin
OpenDialog1.FileName := ' ';
OpenDialog1.Filter := 'Graphic files (*.*)|*.*';
OpenDialog1.Options := [ofFileMustExist, ofNoValidate, ofHideReadOnly];
if OpenDialog1.Execute then
begin
with dmTrans.tblProduct do // this is a TTable component
begin
imgBStream := TBlobStream.Create( (FieldByName( 'ART_IMAGE' ) as
TBlobField), bmWrite );
try
imgFStream := TFileStream.Create( OpenDialog1.FileName,
fmOpenRead );
try
imgBStream.CopyFrom( (imgFStream as TStream),
imgFStream.Size);
finally
imgFStream.Free;
end;
finally
imgBStream.Free;
end;
end;
end;