Einzelnen Beitrag anzeigen

mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.861 Beiträge
 
Delphi 11 Alexandria
 
#21

Re: Bilder in die Paradoxtabelle speichern ?

  Alt 3. Apr 2006, 21:12
Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Grids, DBGrids, DBCtrls, DBTables, DB, ExtDlgs;

type
  TForm1 = class(TForm)
    Query1: TQuery;
    DataSource1: TDataSource;
    UpdateSQL1: TUpdateSQL;
    DBImage1: TDBImage;
    DBGrid1: TDBGrid;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    OpenPictureDialog1: TOpenPictureDialog;
    SavePictureDialog1: TSavePictureDialog;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
query1.append;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
   blob : TMemoryStream;
  // jpeg : TJPEGImage;
   bmp : TBitmap;
   s: String;
begin
    blob := TMemoryStream.Create();
  // jpeg := TJPEGImage.Create;
    bmp := TBitmap.Create;
   TRY
     if OpenpictureDialog1.Execute then
     begin
          s :=ExtractFileExt(OpenPictureDialog1.FileName);
          if uppercase(s) = '.BMPthen
          begin
             bmp.loadfromfile(OpenPictureDialog1.FileName);
             blob.Clear;
             bmp.saveToStream(blob);
          end else
          begin
         // jpeg.LoadFromFile(OpenPictureDialog1.FileName);
             blob.Clear;
         // jpeg.SaveToStream(blob);
          end;
        // query1.SQL.Text := 'Update Tabelle Set Foto = :Bild where ID = :id';
          query1.SQL.Text := 'Insert into losch( Tennis) values( :Bild);';

          query1.ParamByName('bild').LoadFromStream(blob,ftGraphic);
        // query1.ParamByName('id').AsInteger := DM.FahrerID.AsInteger;
          query1.ExecSQL;
     end;
   Finally
      freeandnil(blob);
    // freeandnil(jpeg);
      freeandnil(bmp);
      DBImage1.LoadPicture;
   END
end;



end.
Markus Kinzler
  Mit Zitat antworten Zitat