我给出答案,请您信守诺言,再加100大洋.
//将JPEG文件写入BLOB字段,并显示在IMAGE中
var
m_jpeg:TJpegImage;
begin
m_jpeg:= TJpegImage.Create;
try
try
m_jpeg.LoadFromFile('Photo.jpg');
image1.Picture.Assign(m_jpeg);
table.Edit;
TBlobField(table.FieldByName('照片')).LoadFromFile('Photo.jpg');
except
showmessage('图片文件无效,其格式必须为JPG格式,且不得超过10K,请重新选择.');
end;
finally
m_jpeg.Free;
end;
end;
//读出主表图片字段的图片,显示在IMAGE中
var
m_blob:TBlobStream;
m_jpeg:TJpegImage;
begin
image.Picture:= nil;
m_blob:=TBlobStream.Create(TBlobField(table.FieldByName('照片')),bmRead);
m_jpeg:=TJpegImage.Create;
try
if m_blob.Size<>0 then
begin
try
m_jpeg.LoadFromStream(m_blob);
image.Picture.Assign(m_jpeg);
except
showmessage('主表中图片格式无效(JPG格式),请重新扫描或读入.');
end;
end
finally
m_jpeg.Free;
m_blob.Free;
end;
end;