How To Filter Data In C# Code

Hi
I am a developer and i have use FastReport.Net for my Reports.
I am new user for FastReport.Net and I have a problem.
Please help me that how can I simulate Crystal Reports SelectionFormula in FastReport.Net?
I cant use the Parameter, because my formula is like "SELECT * FROM Table1 WHERE Field1 BETWEEN @FromV AND @ToV AND Field2 IN (1,2,3,4,...)"
Please Help me
Best Regards

Comments

  • pinbotpinbot Texas
    edited 2:32PM

    It's fairly easy.

    Create your sql like this in your c# code:

    string sql="select xxx from yyy where ....";

    then replace the SQL Select Command in the FastReport table data source object:


    (this is from working code):

    FastReport.Utils.Config.WebMode = true;
    FastReport.Report Rpt = new FastReport.Report();
    Rpt.Load(this.Page.Server.MapPath("../App_Data/MyFastReport.Frx"));
    str sql="(my sql that references parameters, etc)"


    FastReport.Data.TableDataSource tds = (FastReport.Data.TableDataSource) Rpt.GetDataSource("VendorGuideSearch");
    tds.SelectCommand = sql;

    Rpt.SetParameterValue("MapIds", MapIds);
    Rpt.Prepare();
    FastReport.Export.Pdf.PDFExport export = new FastReport.Export.Pdf.PDFExport();
    export.PrintOptimized = false;
    export.OpenAfterExport = false;

Leave a Comment