unit
Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, DBTables, DBCtrls, Grids, DBGrids, StdCtrls, ExtCtrls;
type
TForm2 =
class
(TForm)
Button1: TButton;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
DBImage1: TDBImage;
Table1: TTable;
DBNavigator1: TDBNavigator;
Button2: TButton;
procedure
Button1Click(Sender: TObject);
procedure
Button2Click(Sender: TObject);
procedure
FormCreate(Sender: TObject);
private
public
end
;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure
TForm2
.
Button1Click(Sender: TObject);
var
blob: TStream;
begin
blob := form2
.
table1
.
CreateBlobStream(table1
.
FieldByName(
'Pictures'
), bmRead);
try
blob
.
Seek(
0
, soFromBeginning);
with
TFileStream
.
Create(
'c:\1.dwg'
, fmCreate)
do
try
CopyFrom(blob, blob
.
Size)
finally
Free
end
;
finally
blob
.
Free
end
;
end
;
procedure
TForm2
.
Button2Click(Sender: TObject);
var
blob, fs: TStream;
begin
blob := (form2
.
table1
.
CreateBlobStream(form2
.
table1
.
FieldByName(
'pictures'
), bmWrite));
try
blob
.
Seek(
0
, soFromBeginning);
fs := TFileStream
.
Create(
'c:\1.dwg'
, fmOpenRead
or
fmShareDenyWrite);
try
blob
.
CopyFrom(fs, fs
.
Size)
finally
fs
.
Free
end
;
finally
blob
.
Free
end
;
end
;
procedure
TForm2
.
FormCreate(Sender: TObject);
begin
table1
.
Active:=
true
;
end
;
end
.