O
OH
Unregistered / Unconfirmed
GUEST, unregistred user!
问大家个问题,搞了很长时间没弄出来
目的:从数据库中取出图片并显示到image控件中。以下是代码:
procedure TForm1.DBGrid1CellClick(Column: TColumn);
var
ss : TadoBLobStream;
jpegimage : Tjpegimage;
begin
try
adoquery3.close;
adoquery3.Open;
adoquery3.Edit;
jpegimage := Tjpegimage.Create;
jpegimage:=nil;
ss := TadoBlobStream.Create((adoquery3.FieldByName('img') as tblobfield),bmread);
ss.Position := 0;
jpegimage.LoadFromStream(ss);
image2.Picture.Graphic:=jpegimage;
except
on e : Exception do
begin
showmessage(e.Message);
jpegimage.Free;
ss.Free;
exit;
end;
end;
jpegimage.Free;
ss.free;
end;
目的:从数据库中取出图片并显示到image控件中。以下是代码:
procedure TForm1.DBGrid1CellClick(Column: TColumn);
var
ss : TadoBLobStream;
jpegimage : Tjpegimage;
begin
try
adoquery3.close;
adoquery3.Open;
adoquery3.Edit;
jpegimage := Tjpegimage.Create;
jpegimage:=nil;
ss := TadoBlobStream.Create((adoquery3.FieldByName('img') as tblobfield),bmread);
ss.Position := 0;
jpegimage.LoadFromStream(ss);
image2.Picture.Graphic:=jpegimage;
except
on e : Exception do
begin
showmessage(e.Message);
jpegimage.Free;
ss.Free;
exit;
end;
end;
jpegimage.Free;
ss.free;
end;