L
lawzhangqi2005
Unregistered / Unconfirmed
GUEST, unregistred user!
我做一个信息管理系统,用到个人照片存入,但是,在保存按钮的时候有一句话通不过,能否给我解答一下.
============================================
procedure TForm5.BitBtn5Click(Sender: TObject);
var
strm: TMemoryStream;
ext: String;
begin
if image1.picture.Graphic <> nil then //避免image1中无图像保存出错
begin
ext:=extractfileext(openpicturedialog1.FileName ); //取出文件的扩展名
strm := tmemorystream.Create;
try
image1.Picture.Graphic.SaveToStream(strm);
datam.ADOcpxxsr.Edit;
strm.Position:=0;
TBlobField(datam.ADOcpxxsr.FieldByName('myimage')).LoadFromStream(strm);
if uppercase(ext) = '.BMP' then
datam.ADOcpxxsr.FieldByName('isbmp').Value := 1 //BMP型图像数据
else
if (uppercase(ext) = '.JPG') Then
datam.ADOcpxxsr.FieldByName('isbmp').Value := 0; //JPEG型图像数据
datam.ADOcpxxsr.Post;
finally
strm.Free ; //笔者发现如strm采用tblobstream类,程序运行到该语句会出现问题
Application.MessageBox('保存成功,谢谢使用!','提示',MB_ICONASTERISk+MB_OK);
end;
end;
end;
============================================
procedure TForm5.BitBtn5Click(Sender: TObject);
var
strm: TMemoryStream;
ext: String;
begin
if image1.picture.Graphic <> nil then //避免image1中无图像保存出错
begin
ext:=extractfileext(openpicturedialog1.FileName ); //取出文件的扩展名
strm := tmemorystream.Create;
try
image1.Picture.Graphic.SaveToStream(strm);
datam.ADOcpxxsr.Edit;
strm.Position:=0;
TBlobField(datam.ADOcpxxsr.FieldByName('myimage')).LoadFromStream(strm);
if uppercase(ext) = '.BMP' then
datam.ADOcpxxsr.FieldByName('isbmp').Value := 1 //BMP型图像数据
else
if (uppercase(ext) = '.JPG') Then
datam.ADOcpxxsr.FieldByName('isbmp').Value := 0; //JPEG型图像数据
datam.ADOcpxxsr.Post;
finally
strm.Free ; //笔者发现如strm采用tblobstream类,程序运行到该语句会出现问题
Application.MessageBox('保存成功,谢谢使用!','提示',MB_ICONASTERISk+MB_OK);
end;
end;
end;