D
duancy
Unregistered / Unconfirmed
GUEST, unregistred user!
以前我用C/S结构正常,方法是在frDesigner的OnSaveReport事件中添加以下代码
procedure TForm1.frDesigner1SaveReport(Report: TfrReport;
var ReportName: String;
SaveAs: Boolean;
var Saved: Boolean);
var
tempStream : TMemoryStream;
begin
query1.close;
query1.sql.clear;
query1.sql.add('insert into repotable(RptName,RptDesign)');
query1.sql.add('values RptName1,:RptDesign1)');
query1.ParamByName('RptName1').asstring := '报表名称';
tempStream:=TMemoryStream.Create;
tempStream.Clear;
try
Report.SaveToStream(tempStream);
query1.ParamByName('RptDesign1').LoadFromStream(tempStream,ftBlob);
finally
tempStream.Free;
end;
query1.execSQL;
Saved := True;
end;
可是现在改成三层结构就不行了,中间层放了一个query,一个dataSetProvider,
Provider属性[poAllowCommandText]=true;
procedure TForm1.frDesigner1SaveReport(Report: TfrReport;
var ReportName: String;
SaveAs: Boolean;
var Saved: Boolean);
var
tempStream : TMemoryStream;
begin
clientdataSet1.close;
clientdataSet1.commandtext := 'insert into repotable(RptName,RptDesign) values RptName1,:RptDesign1)';
clientdataSet1.Params.ParamByName('RptName1').asstring := '报表名称';
tempStream:=TMemoryStream.Create;
tempStream.Clear;
try
Report.SaveToStream(tempStream);
clientdataSet1.Params.ParamByName('RptDesign1').LoadFromStream(tempStream,ftBlob);
finally
tempStream.Free;
end;
clientdataSet.execute;
Saved := True;
end;
没有任何出错信息,可是保存的报表是空白。
procedure TForm1.frDesigner1SaveReport(Report: TfrReport;
var ReportName: String;
SaveAs: Boolean;
var Saved: Boolean);
var
tempStream : TMemoryStream;
begin
query1.close;
query1.sql.clear;
query1.sql.add('insert into repotable(RptName,RptDesign)');
query1.sql.add('values RptName1,:RptDesign1)');
query1.ParamByName('RptName1').asstring := '报表名称';
tempStream:=TMemoryStream.Create;
tempStream.Clear;
try
Report.SaveToStream(tempStream);
query1.ParamByName('RptDesign1').LoadFromStream(tempStream,ftBlob);
finally
tempStream.Free;
end;
query1.execSQL;
Saved := True;
end;
可是现在改成三层结构就不行了,中间层放了一个query,一个dataSetProvider,
Provider属性[poAllowCommandText]=true;
procedure TForm1.frDesigner1SaveReport(Report: TfrReport;
var ReportName: String;
SaveAs: Boolean;
var Saved: Boolean);
var
tempStream : TMemoryStream;
begin
clientdataSet1.close;
clientdataSet1.commandtext := 'insert into repotable(RptName,RptDesign) values RptName1,:RptDesign1)';
clientdataSet1.Params.ParamByName('RptName1').asstring := '报表名称';
tempStream:=TMemoryStream.Create;
tempStream.Clear;
try
Report.SaveToStream(tempStream);
clientdataSet1.Params.ParamByName('RptDesign1').LoadFromStream(tempStream,ftBlob);
finally
tempStream.Free;
end;
clientdataSet.execute;
Saved := True;
end;
没有任何出错信息,可是保存的报表是空白。