G
gtgtgt
Unregistered / Unconfirmed
GUEST, unregistred user!
我把一些图片以流的方式存入数据库(不能采取存图片路径的方法)并显示,开始都正常,可运行几次后,同样的程序,编译都通过不了,出现'jpeg error #52'提示。
我已经查了以前的很多帖子,开始认为是我存的JPG图片格式不对,换了个图片,开始一切正常,可运行几次后,故障依旧,怎么办?因马上要交工,十分紧急,多谢了!!
程序如下:
procedure TForm1.Button1Click(Sender: TObject);//图片存入数据库
begin
if opendialog1.Execute then
begin
adoTable1.edit;
(adoTable1.FieldByName('photo') as TBlobField).loadfromfile(opendialog1.FileName);
adoTable1.post;
end;
end;
procedure TForm1.DBEdit1Change(Sender: TObject);//随着dbedit1(编号字段)的变化,显示相应的图片
var
m:TMemoryStream;
jpg:TJpegImage;
begin
if not adotable1.fieldbyname('photo').IsNull then
begin
m := TmemoryStream.Create;
jpg := TJpegImage.Create;
try
(adoTable1.FieldByName('photo') as TBlobField).SaveToStream(m);
m.Seek(0,sofrombeginning);
jpg.LoadFromStream(m);
Image1.Picture.bitmap.Assign(jpg);
jpg.Free;
m.Free;
except
end;
end
else
image1.picture.Assign(Nil);
end;
我已经查了以前的很多帖子,开始认为是我存的JPG图片格式不对,换了个图片,开始一切正常,可运行几次后,故障依旧,怎么办?因马上要交工,十分紧急,多谢了!!
程序如下:
procedure TForm1.Button1Click(Sender: TObject);//图片存入数据库
begin
if opendialog1.Execute then
begin
adoTable1.edit;
(adoTable1.FieldByName('photo') as TBlobField).loadfromfile(opendialog1.FileName);
adoTable1.post;
end;
end;
procedure TForm1.DBEdit1Change(Sender: TObject);//随着dbedit1(编号字段)的变化,显示相应的图片
var
m:TMemoryStream;
jpg:TJpegImage;
begin
if not adotable1.fieldbyname('photo').IsNull then
begin
m := TmemoryStream.Create;
jpg := TJpegImage.Create;
try
(adoTable1.FieldByName('photo') as TBlobField).SaveToStream(m);
m.Seek(0,sofrombeginning);
jpg.LoadFromStream(m);
Image1.Picture.bitmap.Assign(jpg);
jpg.Free;
m.Free;
except
end;
end
else
image1.picture.Assign(Nil);
end;