How do I send parameters to Stimulsoft?

roozbeh picture roozbeh · Oct 27, 2013 · Viewed 14.2k times · Source
    public virtual ActionResult GetReportSnapshot()
    {
       var data = (ComparativeBalanceReportDS) TempData["ComparativeSession"];


        StiReport report = new StiReport();
        report.Load(Server.MapPath("~/Content/StimulReports/SampleReport.mrt"));

        report.Compile();

        report["fromDocumentNumber"] = "1";
        report["toDocumentNumber"] = "85";
        return StiMvcViewer.GetReportSnapshotResult(HttpContext, report);
   }

I have stored procedure and execute in designer but I do not send parameters to it and when run App, I get the following error:

Error:SqlCommand.Prepare method requires all variable length parameters to have an explicitly set non-zero Size.

What do I do?

Answer

roozbeh picture roozbeh · Oct 29, 2013

My problem was solved with the following code :

       public virtual ActionResult GetReportSnapshot()
        {
         var data = (ComparativeBalanceReportDS) TempData["ComparativeSession"];       
          StiReport report = new StiReport();
         report.Dictionary.DataStore.Clear();
         report.Load(Server.MapPath("~/Content/StimulReports/SampleReport.mrt"));
         report["@enterpriseId"] = data.EnterpriseId;
         report["@toDocumentNumber"] = data.NumberFilter.FromDocumentDocumentNumber;
         report["@fromDocumentNumber"] = data.NumberFilter.ToDocumentDocumentNumber;
         report["@fromDate"] = data.DateFilter.FromDocumentDate.Value;
         report["@toDate"] = data.DateFilter.ToDocumentDate.Value;
         return StiMvcViewer.GetReportSnapshotResult(HttpContext, report);

        }