在access用OLE对象,在sql server里用image或binary存储流!存jpeg用image不能用dbimage
uses jpeg,
存
if not(query1.State in [dsEdit, dsInsert]) then exit;
if OpenDialog1.Execute then
begin
(query1.FieldByName('img') as TBlobField).LoadFromFile(OpenDialog1.FileName);
Image1.Picture.LoadFromFile(OpenDialog1.FileName);
end;
显
var
JP: TJPEGImage;
bs: TBlobStream;
begin
if not query1.FieldByName('img').IsNull then
begin
bs := TBlobStream.Create((query1.FieldByName('img') as TBlobField), bmRead);
jp := TJPEGImage.Create;
jp.LoadFromStream(bs);
Image1.Picture.Assign(jp);
bs.Free;
jp.Free;
end
else
Image1.Picture:=nil;