PARADOX表不能保存JPG图像,只能用流的方式 ,下面的两段程序分别是表T1的BEFORPOST和
AFTETSCROLL两个事件中添加代码!我是用流的方式!!
procedure Txkfm.t1BeforePost(DataSet: TDataSet);
var myjpg: tjpegimage;
MS: TMemoryStream;
begin
t1.FieldByName('txm').AsString:='*'+t1.fieldbyname('bh').AsString+'*';
if trim(image1.Picture.GetNamePath)<>'' then
begin
myjpg:=tjpegimage.Create;
ms:=tmemorystream.Create;
try
begin
myjpg.Assign(image1.Picture.Graphic);
myjpg.SaveToStream(MS);
MS.Position:=0;
if not(t1.State in [dsedit,dsinsert]) then
t1.Edit;
TBlobField(T1.FieldbyName('zp')).LoadFromStream(MS);
end;
except
application.MessageBox('非照片文件','错误',mb_ok);
ms.Free;
abort;
end;
end;
myjpg.Free;
ms.Free;
end;
procedure Txkfm.t1AfterScroll(DataSet: TDataSet);
var MS: TMemoryStream;
myjpg: tjpegimage;
begin
image1.Picture.Bitmap.FreeImage;
if not t1.FieldByName('zp').IsNull then
begin
myjpg:=tjpegimage.Create;
ms:=tmemorystream.Create;
try
begin
TBlobField(T1.FieldbyName('zp')).savetoStream(MS);
ms.Position:=0;
myjpg.LoadFromStream(ms);
image1.Picture.Assign(myjpg);
myjpg.Free;
ms.Free;
end;
except
application.MessageBox('非照片文件','错误',mb_ok);
myjpg.Free;
ms.Free;
abort;
end;
end;
end;