Setting Parameter Values

Stimulsoft Reports.NET discussion
Post Reply
rumblecow
Posts: 33
Joined: Fri Nov 08, 2013 3:47 pm

Setting Parameter Values

Post by rumblecow »

When setting the parameter values as follows:

Code: Select all

                    report.Load(Server.MapPath("~/Content/Reports/Stock Usage Detail.mrt"));
                    report["FromDate"] = new DateTime(2010,10,1);
                    report["ToDate"] = new DateTime(2014,4,1);
                    report["ItemNumber"] = "4202802";
why does the following expression continue to show the original value of the parameters?

{TransMonthDetail.Parameters["FromDate"].ParameterValue} through {TransMonthDetail.Parameters["ToDate"].ParameterValue}
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Setting Parameter Values

Post by Alex K. »

Hello,

The following code wokrs only for compiled report:
report["ParamName"] = value

Please try to use the following code:
report.Dictionary.DataSources["DataSourceName"].Parameters["ParameterName"].Value = "";

Thank you.
rumblecow
Posts: 33
Joined: Fri Nov 08, 2013 3:47 pm

Re: Setting Parameter Values

Post by rumblecow »

Aleksey wrote:Hello,

The following code wokrs only for compiled report:
report["ParamName"] = value

Please try to use the following code:
report.Dictionary.DataSources["DataSourceName"].Parameters["ParameterName"].Value = "";

Thank you.
I've tried passing the value in the following string format but receiving 'failed to convert parameter value from Int32 to a DateTime. I've also tried new DateTime(2010, 10, 1).ToString(); but receive an exception in ...AppData\Local\Temp\hogrghq2.0.cs.

Code: Select all

                    report.Load(Server.MapPath("~/Content/Reports/Stock Usage Detail.mrt"));
                    report.Dictionary.DataSources["TransMonthDetail"].Parameters["FromDate"].Value = "10/1/2010";
                    report.Dictionary.DataSources["TransMonthDetail"].Parameters["ToDate"].Value = "4/1/2014";
                    report.Dictionary.DataSources["TransMonthDetail"].Parameters["ItemNumber"].Value  = "4202802";
How should a date string be passed? The parameter is defined as Date and not DateTime.
The query definition is:

Code: Select all

SELECT	TransDate,		
		SiteID,
		Item,
		ItemClass,
		Description1,
		TypeDescription,
		Cost,
		Quantity
FROM	TRANS
INNER JOIN Crib ON TRANS.Crib = Crib.Crib 
INNER JOIN INVENTRY ON TRANS.Item = INVENTRY.ItemNumber
WHERE	(TypeDescription IN ('ADJUS', 'CANCL', 'COUNT', 'ISSRT', 'ISSUE', 'RETN', 'RETNW', 'SCRAP', 'SCRPR')
		AND (Transdate >= @FromDate AND TransDate < @ToDate)
		AND (Item = @ItemNumber))
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Setting Parameter Values

Post by Alex K. »

Hello,

Please try to use the following code for datatime parameters:

Code: Select all

report.Dictionary.DataSources["TransMonthDetail"].Parameters["FromDate"].Value = "\"10/1/2010\"";
Thanky ou.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Setting Parameter Values

Post by HighAley »

Hello.

Please, try to use next code:

Code: Select all

report.Dictionary.Variables["Variable1"].ValueObject = DateTime.Today;
Thank you.
rumblecow
Posts: 33
Joined: Fri Nov 08, 2013 3:47 pm

Re: Setting Parameter Values

Post by rumblecow »

I've since changed from using two date parameter to a single DateTimeRange variable based on https://www.youtube.com/watch?v=O5AvgJjbzGo.

The variable and parameter are set as follows:

Code: Select all

report.Load(Server.MapPath("~/Content/Reports/Stock Usage Detail.mrt"));
Stimulsoft.Report.[color=#0000FF]DateTimeRange[/color] dtr = new Stimulsoft.Report.DateTimeRange(new DateTime(2010, 10, 1), new DateTime(2014, 04, 01));
report.Dictionary.Variables.Add("Dates", dtr);
report.Dictionary.DataSources["TransMonthDetail"].Parameters["ItemNumber"].Value = "4202802";
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Setting Parameter Values

Post by Alex K. »

Hello,

In this case you can use this variable in parameters expressions:
for FromDate paramter dtr.From, for ToDate paramter dtr.To

Thank you.
Post Reply