Hi,
so, meanwhile, everything works...
But I want -as a Payback- show how i finally solved it..
maybe it is helpfull for others...
The problem was, that i did not want to
pre-define te Fields at Design Time...
Here is a small snippet...
Thats another way how it works
and the Fields can be created at runtime..
.....
// Remark: The Table has already been created at an earlier Step..
// something lke:
// 'CREATE TABLE BLOB_Data ( Name VARCHAR(255), Typ VARCHAR(255), Datasize Integer, Data BLOB ); ';
// DB1 -> your Database
// DS1 -> your Dataset
procedure TForm1.SpeedButton4Click(Sender: TObject);
Var
blob : TStream;
fs : TFileStream;
fsz : Integer;
FN : String;
Ext : String;
FName : String;
Text1,
Text2,
Value1 : TField;
begin
If not DB1.Connected then exit;
Opendialog2.InitialDir := OutDir;
If Opendialog2.Execute then begin
Fname := Opendialog2.FileName;
Ext := ExtractFileExt ( FName );
FN := ExtractFileName ( FName );
Delete ( FN, Pos ( Ext, FN ), Length ( Ext ));
DS1.Active := False; // needed to set DB
DS1.Database := DB1;
DS1.Active := True;
// just some Text Fields and an Integer...
Text1 := DS1.FieldByName ('Name');
Text2 := DS1.FieldByName ('Type');
Value1 := DS1.FieldByName ('Datasize');
DS1.Insert;
DS1.Edit;
Blob := DS1.CreateBlobStream ( DS1.FieldByname ('Data'),bmWrite );
Try
// Application.ProcessMessages; // not really needed i use it for own purposes
blob.Seek(0, soFromBeginning); // important !
fs := TFileStream.Create ( Fname, fmOpenRead or fmShareDenyWrite );
fsz := fs.Size;
try
blob.CopyFrom ( fs, fsz);
finally
fs.Free;
end;
Finally
Blob.Free;
end;
Text1.AsString := FN;
Text2.AsString := Ext;
Value1.AsInteger := fsz;
DS1.Post;
end
else Exit;
end;
....
Thats it..
Maybe this Post does not really fit in this
Thread, (->"Thanks for your components")
-anyways the thanks are ment as said-
so Luc, feel free to place its somewere else..
I didnt know how...
Wolfy
...nice Easter Eggs...