Pass DateTime parameter to LocalReport?

C

cpnet

I'm able to pass string parameters with no problems to a LocalReport being
displayed by the ASP.NET ReportViewer control. However, my report also has
a DateTime parameter. LocalReport.SetParameters(..) only seems to allow me
to set string parameters. Is there a way to pass DateTime (or other types)
of parameters? Or can I only use string parameters in a LocalReport if I
need to pass them in from my ASP.NET app?

Thanks,
cpnet
 
L

Luke Zhang [MSFT]

Hello,

The method LocalReport.SetParameters(..) can accept ReportParameter object
as its parameters. However, ReportParameter can only be initialized with
string value. So, we can only pass string to SetParameters(..) method.
Regarding the issue, can you change the required parameter for the report
to string value, for example a string with datatime value like '1/1/2007'?


Sincerely,

Luke Zhang

Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
C

cpnet

That's what I had to do to get it working. But it means I also have to
change the LocalReport parameters to the string type. And that means a lot
of extra type conversions if I want to use such parameters as actual dates
in the report.
 
L

Luke Zhang [MSFT]

Hello,

I don't think we have to change the actual parameter in the report. For
example, we have a parameter named "CurDate" in the report, and its data
type is "DateTime", we can pass a string value like '1/1/2007' to it
directly with SetParameters. Here is the document for SetParameters:

http://msdn2.microsoft.com/en-us/library/microsoft.reporting.winforms.server
report.setparameters(VS.80).aspx

Sincerely,

Luke Zhang

Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
C

cpnet

I understand that I can convert a DateTime to a string, pass it to the
report in a ReportParameter as a string, then use it in the report. But if
I want to use some date functions in the report (like DateDiff, DateAdd)
etc., then I have to convert that string back to a DateTime in the Report
before using those report functions. It would be a lot more efficient to be
able to pass it in as a DateTime.

A LocalReport supports DateTime parameters, unfortunately as far as I can
tell, ReportParameter can only be used to set LocalReport parameters of type
string (which is a real limitation in my opinion).

When I tried to pass in MyDateTime.ToString() to a DateTime parameter, I got
errors. I was only able to pass in string values to String parameters.
Maybe my problem is that DateTime.ToString() formats the DateTime value
incorrectly, but I doubt this was the case because this was all running on
the same machine which should have consistent regional settings. I suspect
that I can in fact only assign values for string parameters. Even if the
reason for my errors was that I wasn't formatting my date string properly,
that just exposes another problem with using strings instead of other
types - you always have to worry about how you're formatting your strings so
that they can be converted back to the relevant type at the report's side of
things.

So, I guess this should go on the feature request list for the next .NET?
 
L

Luke Zhang [MSFT]

Hello,

If you consider this is necessary feature, I suggest you may submit a
feedback on this page:

http://connect.microsoft.com/site/sitehome.aspx?SiteID=210

Our dev team will collect all the feedback and bring them to consideration
for next release.

Sincerely,

Luke Zhang

Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
K

Kim Chan

Hi there,

I have the same problem like many others trying to set a parameter to a local report(see below):

Dim myReportParams(0) As ReportParameter
myReportParams(0) = New ReportParameter("str_rpt_date", "2007/07/01")
Me.ReportViewer1.LocalReport.SetParameters(myReportParams)
Me.ReportViewer1.LocalReport.Refresh()

Any ideas why the myReportParams(0) is not set the value? I can see that the myReportParams(0) NAME is set correctly (ie. "str_rpt_date") thru the debugger though. When I look at the value for myReportParams(0), it gives the following message:

"In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user."

Thanks,

KC

Posted via DevelopmentNow.com Group
http://www.developmentnow.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top