Re: Saving Image/Picture to Database using ADO



I tried both of theses options and still get the same 'Bitmap Image is
Invalid' Error message.

qryCompanyLOGO.LoadFromFile(SPicFileName);
(qryCompany.fieldbyName('LOGO') as TblobField).loadFromfile(SPicFileName);

The jpeg is valid because it will load into my DBImage with the following
code:

Pic:=TJpegImage.Create;
try
Pic.LoadFromFile(FileName);
finally
DBImage1.Picture.Assign(Pic);
end

The database field in the MSSQL Database is of type 'image'.
I am using a TADOQuery as my datasource.
Is there any reason why either of the top two options would not work?

"Brian Bushay TeamB" <BBushay@xxxxxxxxx> wrote in message
news:dbfgj21j1jsjnimped0n1vql65bp3re2d0@xxxxxxxxxx
procedure TfrmCompany.SaveJpegToTable(Table: TADOQuery;
PicField:TBlobField;
sPicPath: string);
{
Usage:

SPicFileName := 'C:\!gajba\cdcovers\cdcover1.jpg';
SaveJpegToTable(ADOTable1, ADOTable1Picture, SPicFileName);
}
var
fS : TFileStream;
begin
// fs:=TFileStream.Create(sPicPath, fmOpenRead);
fs:=TFileStream.Create(PicField, fmOpenRead);
try
Table.Edit;
// JpegStartsInfs(PicField, fs);
PicField.LoadFromStream(fs);
Table.Post;
finally
fs.Free;
end;
end;

Any help would be appreciated.

Thanks,
Leonard


Table.Edit;
( Table.fieldbyName('picfield') as
TblobField).loadFromfile(SPicFileName);
Table.Post;

--
Brian Bushay (TeamB)
Bbushay@xxxxxxxxx


.


Quantcast