**写
var
aMStream: TMemoryStream;
aBStream: TBlobStream;
str :String;
begin
str:='c:/hello.jpg';
aMStream := TMemoryStream.Create();
try
aMStream .LoadFromFile(str);
ADOTable1.Append;
aBStream := TBlobStream.Create(TBlobField(ADOTable1.FieldByName('jpg')), bmWrite);
aMStream.SaveToStream(aBStream );
ADOTable1.Post;
finally
aMStream .Free;
end;
end;
** 读
var
aJPG: TJpegImage;
aBStream: TBlobStream;
str :String;
begin
str:='c:/hello.jpg';
if ADOTable1.FieldByName('jpg').IsNull then
begin
Application.MessageBox('无图像!','提示',MB_IconInformation+MB_OK);
Exit;
end;
aJPG := TJPEGImage.Create();
with aJPG do
try
aBStream := TBlobStream.Create(TBlobField(ADOTable1.FieldByName('Bmp')), bmRead);
try
aJPG.LoadFromStream(aBStream);
aJPG.SaveToFile(str);
finally
aBStream.Free;
end;
finally
aJPG.Free;
end;
end;