[
]
unit Unit1;
interface
uses
Windows, Messages, jpeg, Sysutils, DBTables, Db, Dialogs, ExtDlgs,Controls, StdCtrls,
Buttons, Classes, Graphics, Forms, Menus, ExtCtrls, ComCtrls, ToolWin,
ImgList,StdActns, DBCtrls, Grids,winprocs, DBGrids;
type
TForm1 = class(TForm)
……
在query里定义一个函数:tx_temp2(在它的SQL里)
procedure TForm1.BitBtn1Click(Sender: TObject); //存储
var jpegs:TJpegImage;
mstream: tstringstream;
begin
jpegs:=TJpegImage.Create;
jpegs.Assign(image1.Picture.Graphic);
mstream:=Tstringstream.create('');
jpegs.SaveToStream(mStream);
query1.SQL.Clear;
query1.SQL.add('insert into table1(a) values
tx_temp2)');
query1.Params[0].AsBlob:=mstream.DataString;
query1.execsql;
end;
显示
procedure TForm1.BitBtn2Click(Sender: TObject);
var
mStream: tstream;
Jpegs: TJpegImage;
begin
query1.close ;
query1.sql.clear ;
query1.sql.text:='select * from table1 where 条件';
query1.open ;
jpegs:=TJpegImage.Create;
mStream :=Query1.CreateBlobStream(Query1.FieldByName('passer_picture'),bmRead);
try
mstream.Position:=0;
if mstream.Size>0 then
begin
jpegs.LoadFromStream(mstream);
image2.Picture.Assign(jpegs);
end
else
begin
image2.Picture.Assign(nil);
end;
finally
jpegs.Free;
mstream.Free;
end;
end;
这样好象是应该可以了我没有使用dbimage直接用image也可以实现显示的作用