Subject | Re: Sample Delphi code? |
---|---|
Author | yahdominiek |
Post date | 2005-11-07T14:04:44Z |
Hi,
With DBXpress & Delphi 6 I do it like this :
the BlobField is 'BRIEF'
odNieuws: TOpenDialog;
FSize : Int64;
FS : TFileStream;
FName := ExtractFileName(odNieuws.FileName);
FSize := fMain.GetFileSize(FName);
GetMem(buf, FSize);
fs := TFileStream.Create(FName, fmOpenRead);
try try
fs.ReadBuffer(buf^, FSize);
PutFile;
SendMessages; // not relevant here
AddNB; // not relevant here
except
on E: Exception do begin
MessageDlg(E.ClassName + #13#10+E.Message, mtError, [mbOk], 0);
end;
end;
finally
FreeMem(Buf);
fs.Free;
end;
PutFile is (snipped) :
(QryUp: TSQLQuery; // with Params set up correctly)
QryUp.SQL.Clear;
QryUp.SQL.Add('INSERT INTO NEWSLETTERS (FILENAME, FILESIZE, DESCR,
KH1, KH2, KH3, KH4, BRIEF, DATUM, VST) '+
'VALUES (:prmName, :prmSize, :prmOms, :prmkh1,
:prmkh2, :prmkh3, :prmkh4, :prmBrief, CAST(''NOW'' AS DATE), :prmVest)');
QryUp.Params[0].AsString := FName;
QryUp.Params[1].AsInteger := FSize;
QryUp.Params[2].AsString := FDescr;
QryUp.ParamByName('prmBrief').LoadFromStream(FS, ftBlob);
QryUp.Params[3].AsSmallInt := 0;
QryUp.Params[4].AsSmallInt := 0;
QryUp.Params[5].AsSmallInt := 0;
QryUp.Params[6].AsSmallInt := 0;
QryUp.Params[8].AsString := sNowVest;
QryUp.ExecSQL();
qryUp.Close;
(with exception handling offcourse, but not shown cos too much and
not relevant)
Not sure about the possibilities of FIBPlus, but it should generally
be alike.
Greetz,
Dominiek D'hondt
Eximco Bvba
Bruges, Belgium
--- In firebird-support@yahoogroups.com, "Myles Wakeham" <myles@t...>
wrote:
With DBXpress & Delphi 6 I do it like this :
the BlobField is 'BRIEF'
odNieuws: TOpenDialog;
FSize : Int64;
FS : TFileStream;
FName := ExtractFileName(odNieuws.FileName);
FSize := fMain.GetFileSize(FName);
GetMem(buf, FSize);
fs := TFileStream.Create(FName, fmOpenRead);
try try
fs.ReadBuffer(buf^, FSize);
PutFile;
SendMessages; // not relevant here
AddNB; // not relevant here
except
on E: Exception do begin
MessageDlg(E.ClassName + #13#10+E.Message, mtError, [mbOk], 0);
end;
end;
finally
FreeMem(Buf);
fs.Free;
end;
PutFile is (snipped) :
(QryUp: TSQLQuery; // with Params set up correctly)
QryUp.SQL.Clear;
QryUp.SQL.Add('INSERT INTO NEWSLETTERS (FILENAME, FILESIZE, DESCR,
KH1, KH2, KH3, KH4, BRIEF, DATUM, VST) '+
'VALUES (:prmName, :prmSize, :prmOms, :prmkh1,
:prmkh2, :prmkh3, :prmkh4, :prmBrief, CAST(''NOW'' AS DATE), :prmVest)');
QryUp.Params[0].AsString := FName;
QryUp.Params[1].AsInteger := FSize;
QryUp.Params[2].AsString := FDescr;
QryUp.ParamByName('prmBrief').LoadFromStream(FS, ftBlob);
QryUp.Params[3].AsSmallInt := 0;
QryUp.Params[4].AsSmallInt := 0;
QryUp.Params[5].AsSmallInt := 0;
QryUp.Params[6].AsSmallInt := 0;
QryUp.Params[8].AsString := sNowVest;
QryUp.ExecSQL();
qryUp.Close;
(with exception handling offcourse, but not shown cos too much and
not relevant)
Not sure about the possibilities of FIBPlus, but it should generally
be alike.
Greetz,
Dominiek D'hondt
Eximco Bvba
Bruges, Belgium
--- In firebird-support@yahoogroups.com, "Myles Wakeham" <myles@t...>
wrote:
>using
> I have to store some images in a Delphi 7 application I'm designing,
> FIBPlus, and was wondering if anyone could point me in the rightdirection
> for some example code on handling the storing of images from Delphi into
> BLOBs in Firebird?
>
> All help greatly appreciated.
>
> Thanks
> Myles
>
> ===========================
> Myles Wakeham
> Director of Engineering
> Tech Solutions Inc.
> Scottsdale, Arizona USA
> Phone (480) 451-7440
> Web: www.techsol.org
>