Reading Report DataSet's

edited January 2008 in FastReport 3.0
Hello,

Is there a way to read wich DataSet's (TfrxDBDataSet) does a .fr3 report use? A TStringList or a comma separated String with the used DataSets names should works fine. [img]style_emoticons/<#EMO_DIR#>/wink.gif" style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" /> Thanks in advance.[/img]

Comments

  • edited January 2008
    I found the solution:
        Report.LoadFromFile( ChangeFileExt( Application.ExeName, '.fr3' ) );
        If Report.DataSets.Count > 0 Then
            ShowMessage( Report.DataSets[0].DataSetName );
    

    Some modifications and this should works fine. [img]style_emoticons/<#EMO_DIR#>/wink.gif" style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" /> Thanks.[/img]
  • edited 6:25AM
    Well, that wasn't so wasy as I thought.

    This procedure is returning the error 'DataSet "" does not exists':
    Procedure TFormCadastro.ShowReport( wResName : String; AdditionalVars : TStringList );
    Var Report : TfrxReport;
        DataSets : Array Of TfrxDBDataSet;
        Stream : TResourceStream;
        wI : Integer;
        DataSetName : String;
    Begin
        Report := TfrxReport.Create( Self );
    
        Try
            Stream := TResourceStream.Create( hInstance, wResName, 'FRREPORT' );
            Try
                Report.LoadFromStream( Stream );
            Finally
                FreeAndNil( Stream );
            End;
    
            For wI := 0 To Report.DataSets.Count - 1 Do Begin
                DataSetName := Report.DataSets[wI].DataSetName;
                SetLength( DataSets, wI + 1 );
                DataSets[wI] := TfrxDBDataSet.Create( Report );
                DataSets[wI].Name := DataSetName;
                DataSets[wI].UserName := DataSetName;
    
                If AnsiCompareText( DataSetName, 'DataSet' ) = 0 Then
                    DataSets[wI].DataSet := fcDataSet
                Else If FindComponent( 'H' + DataSetName ) Is TDataSet Then
                    DataSets[wI].DataSet := TDataSet( FindComponent( 'H' + DataSetName ) );
            End;
    
            Report.Variables.Clear;
            With Report.Variables.Add Do
                Name := ' Datafron';
            With Report.Variables.Add Do Begin
                Name := 'wSistema';
                Value := AnsiQuotedStr( wSistema, '''' );
            End;
            With Report.Variables.Add Do Begin
                Name := 'wApp';
                Value := AnsiQuotedStr( wApp, '''' );
            End;
            With Report.Variables.Add Do Begin
                Name := 'wEmpresa';
                Value := AnsiQuotedStr( wEmpresa, '''' );
            End;
            With Report.Variables.Add Do Begin
                Name := 'wUsuario';
                Value := AnsiQuotedStr( wUsuario, '''' );
            End;
    
            If Assigned( AdditionalVars ) Then
                For wI := 0 To AdditionalVars.Count - 1 Do
                    With Report.Variables.Add Do Begin
                        Name := AdditionalVars.Names[wI];
                        Value := AnsiQuotedStr( AdditionalVars.Values[Name], '''' );
                    End;
    
            If Report.PrepareReport Then
                Report.ShowPreparedReport;
        Finally
            FreeAndNil( Report );
        End;
    End;
    
    How can I fix this problem?

    Thanks.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.