By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,783 Members | 1,347 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,783 IT Pros & Developers. It's quick & easy.

Pass DateTime parameter to LocalReport?

P: n/a
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
Jan 31 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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/subscripti...ult.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/subscripti...t/default.aspx.
==================================================

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

Jan 31 '07 #2

P: n/a
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.
Jan 31 '07 #3

P: n/a
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/lib...informs.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/subscripti...ult.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/subscripti...t/default.aspx.
==================================================

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

Feb 1 '07 #4

P: n/a
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?
Feb 2 '07 #5

P: n/a
Hello,

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

http://connect.microsoft.com/site/si...spx?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/subscripti...ult.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/subscripti...t/default.aspx.
==================================================

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

Feb 2 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.