Delphi 把单张图片保存到Access数据库

procedure TForm1.BitBtn2Click(Sender: TObject);
var ext:string;
begin
  openpicturedialog1.FileName :='.jpg';
If OpenPictureDialog1.Execute Then
 begin
   image1.Picture.LoadFromFile(openpicturedialog1.FileName );
      if image1.picture.Graphic <> nil then  
    begin
       adoquery1.Edit;
       adoquery1.FieldByName('图片').Assign(image1.Picture.Graphic);
       ext:=extractfileext(openpicturedialog1.FileName );
   if uppercase(ext) = '.BMP' THEN
      adoquery1.FieldByName('格式').VALUE :='bmp'
   ELSE
     IF (UPPERCASE(EXT) = '.JPEG') OR (UPPERCASE(EXT) = '.JPG') THEN
      adoquery1.FieldByName('格式').VALUE := 'jpg';
   adoquery1.Post;
   end;
end;
end;

 

你可能感兴趣的:(Delphi)