没有SQL Server ,以下示例在本地数据库中可行:
uses JPEG;
procedure TForm1.SaveBtnClick(Sender: TObject);
begin
if OpenPictureDialog1.Execute then
begin
if not(Table1.State in [dsEdit, dsInsert]) then Table1.Edit;
(Table1.FieldByName('photo') as TBlobField).LoadFromFile(OpenPictureDialog1.FileName);
Table1.Post;
end;
end;
procedure TForm1.ShowBtnClick(Sender: TObject);
var
JP: TJPEGImage;
bs: TBlobStream;
begin
bs := TBlobStream.Create((Table1.FieldByName('photo') as TBlobField), bmRead);
jp := TJPEGImage.Create;
jp.LoadFromStream(bs);
Image1.Picture.Assign(jp);
bs.Free;
jp.Free;
end;