Registriert seit: 26. Aug 2004
Ort: Nebel auf Amrum
3.154 Beiträge
Delphi 7 Enterprise
|
Re: SQL Server und FileStreams
12. Aug 2006, 17:20
Hallo renekr,
versuch es doch mal so...
Delphi-Quellcode:
procedure LoadRave(Spalte: string; Query:TADOQuery; Rave:TRvProject);
var Stream:TStream;
Field:TField;
begin
if assigned( Query) and assigned(Rave) then begin
if Query.Active then begin
Field:= Query.FieldByName(Spalte);
if assigned(Field) then begin
if Field.IsBlob then begin
Stream:= Query.CreateBlobStream(Field, bmRead);
try
Rave.New;
Rave.LoadFromStream(Stream);
finally
Stream.Free;
end;
end;
end;
end;
end;
end;
procedure SaveRave(Spalte: string; Query:TADOQuery; Rave:TRvProject);
var Stream:TStream;
Field:TField;
begin
if assigned( Query) and assigned(Rave) then begin
if Query.Active then begin
Field:= Query.FieldByName(Spalte);
if assigned(Field) then begin
if Field.IsBlob then begin
Query.Edit;
Stream:= Query.CreateBlobStream(Field, bmWrite);
try
Rave.SaveToStream(Stream);
finally
Stream.Free;
end;
Query.Post;
end;
end;
end;
end;
end;
Aufruf:
Delphi-Quellcode:
procedure TForm.RaveLadenClick(Sender: TObject);
begin
ADOquery1.SQL.Text:=
' SELECT *'#13 +
' FROM _Test_Rave'#13 +
' WHERE id = 12';
ADOquery1.Open;
LoadRave(' rave', ADOQuery1, RaveProject);
end;
procedure TForm.RaveSpeichernClick(Sender: TObject);
begin
// Query muss offen sein, Rave wird in aktueller Zeile gespeichert
RaveProject.New;
SaveRave(' rave', ADOQuery1, RaveProject);
end;
Gruss
Thorsten
|
|
Zitat
|