R
red_blue
Unregistered / Unconfirmed
GUEST, unregistred user!
代码如下:
procedure TForm2.Button1Click(Sender: TObject);
var
imPicture: TJpegImage;
jpeg : TJpegImage;
imStream: TMemoryStream;
begin
if OpenPictureDialog1.execute then
Image1.Picture.LoadFromFile(OpenPictureDialog1.FileName);
imPicture := TJpegImage.create;
imPicture.Assign(Image1.Picture.Graphic);
imStream := TMemoryStream.Create;
imStream.Clear;
imPicture.SaveToStream(imStream);
FreeAndNil(imPicture);
ADOQuery1.edit;
TBlobField(ADOQuery1.FieldByName('个人图片')).LoadFromStream(imStream);
ADOQuery1.Post;
jpeg := TJpegImage.Create;
imStream.Clear;
ADOQuery1.Edit;
TBlobField(ADOQuery1.FieldByName('个人图片')).SaveToStream(imStream);
ADOQuery1.Post;
imStream.Position := 0;
jpeg.LoadFromStream(imStream);
DBImage1.Picture.Assign(jpeg);
FreeAndNil(jpeg);
end;
end.
有想在数据库中插入一条新记录,不想覆盖以前的记录,但执行几次还是只有一条记录,怎么能生成新记录,或在最后一条记录后插入一条新记录
procedure TForm2.Button1Click(Sender: TObject);
var
imPicture: TJpegImage;
jpeg : TJpegImage;
imStream: TMemoryStream;
begin
if OpenPictureDialog1.execute then
Image1.Picture.LoadFromFile(OpenPictureDialog1.FileName);
imPicture := TJpegImage.create;
imPicture.Assign(Image1.Picture.Graphic);
imStream := TMemoryStream.Create;
imStream.Clear;
imPicture.SaveToStream(imStream);
FreeAndNil(imPicture);
ADOQuery1.edit;
TBlobField(ADOQuery1.FieldByName('个人图片')).LoadFromStream(imStream);
ADOQuery1.Post;
jpeg := TJpegImage.Create;
imStream.Clear;
ADOQuery1.Edit;
TBlobField(ADOQuery1.FieldByName('个人图片')).SaveToStream(imStream);
ADOQuery1.Post;
imStream.Position := 0;
jpeg.LoadFromStream(imStream);
DBImage1.Picture.Assign(jpeg);
FreeAndNil(jpeg);
end;
end.
有想在数据库中插入一条新记录,不想覆盖以前的记录,但执行几次还是只有一条记录,怎么能生成新记录,或在最后一条记录后插入一条新记录