水
水刃
Unregistered / Unconfirmed
GUEST, unregistred user!
FROM1含AdoConnection、ADOQuery、Datasource、DBGrid三个控件,连接的数据表中含有“照片”列,为image类型,程序用文件流的方式存储图片到照片列,FORM2中含有image、多个DBEdit,在FORM1中的DBGrid的单元格双击事件中弹出FORM2以显示当前单条记录并在image显示“照片”列中存储的图片
在UNIT2中:
procedure TForm2.FormCreate(Sender: TObject);
var
mStream:TMemoryStream;
JpgFile:TjpegImage;
begin
mStream:=TMemoryStream.Create ;
TBlobField(Form1.ADOQuery1.FieldByName('照片')).SaveToStream(mStream); //
mStream.Position :=0;
JpgFile:=TjpegImage.Create ;
jpgfile.LoadFromStream(MStream);
image1.Picture.Bitmap.Assign(JpgFile);
end;
UNIT1中 :
procedure TForm1.DBGrid1DblClick(Sender: TObject);
var
Form2:TForm2;
begin
Form2:=TForm2.Create(self);
Form1.Show;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
adoquery1.Active:=true;
end;
但是运行提示错误:[Error] UNIT2.pas(91): Illegal character in input file: ' ' ($A1A1)不明白是什么意思一直没有改对,请大家帮忙修改多谢!
在UNIT2中:
procedure TForm2.FormCreate(Sender: TObject);
var
mStream:TMemoryStream;
JpgFile:TjpegImage;
begin
mStream:=TMemoryStream.Create ;
TBlobField(Form1.ADOQuery1.FieldByName('照片')).SaveToStream(mStream); //
mStream.Position :=0;
JpgFile:=TjpegImage.Create ;
jpgfile.LoadFromStream(MStream);
image1.Picture.Bitmap.Assign(JpgFile);
end;
UNIT1中 :
procedure TForm1.DBGrid1DblClick(Sender: TObject);
var
Form2:TForm2;
begin
Form2:=TForm2.Create(self);
Form1.Show;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
adoquery1.Active:=true;
end;
但是运行提示错误:[Error] UNIT2.pas(91): Illegal character in input file: ' ' ($A1A1)不明白是什么意思一直没有改对,请大家帮忙修改多谢!