如题,我的解决办法是在delphi中建一个Dataset可是我不知到如何在不建表的情况下动态的建Dataset。而且这个办法太麻烦!有没有更好的办法??

解决方案 »

  1.   

    可以使用TClientDataSet来建立表
      

  2.   

    var sList:TStrings
          
    if sList.Count>0 then
          begin
            DSetMain.Close;
            DSetMain.FieldDefs.Clear;
            for i:=0 to sList.Count-1 do
            begin
              if DSetMain.FieldDefs.IndexOf(GetText('ID',sList.Strings[i]))=-1 then
                DSetMain.FieldDefs.Add(GetText('ID',sList.Strings[i]),ftString,256,false);
            end;
            DSetMain.CreateDataSet;        FRReport.Dictionary.FieldAliases['DSetMain']:='主表数据';
            DSetMain.Edit;
            for i:=0 to sList.Count-1 do
            begin
              DSetMain.Fields.Fields[i].Value:=GetText('VALUE',sList.Strings[i]);
            end;
      

  3.   

    clientData怎么和fastreport 一块使用呀??
      

  4.   

    ClientDataSet放入Form以后,只要设置frDBDataSet的DataSet属性为ClientDataSet就行了。ClientDataSet的数据集在程序中创建。
      

  5.   

    楼主,要打印变量,直接为它赋值不就完了吗,还要建啥子表。真搞不懂。
    procedure TForm1.frReport1GetValue(const ParName: String;
      var ParValue: Variant);
    begin
      if ParName='CustomVar' then
         ParValue := '变量值'
    end;
      

  6.   

    to:hlb1111(蜀狼) 
        有些特殊的原因,需要把这些变量变成单条记录的数据集,比如这些变量个数很多的情况下;还有就是这些变量变成数据集之后,使用非常方便,再加上使用中文字段,非常适合用户自定义报表。