sasi.k.....thanks for the advice but it just did not work for me.
I had to declare the textbox values (populated from calendar control) as strings and then pass them through to the reports procedure which converted them in sql to datetime fields.
This is the only way i could get it to work properly so whoever marked the previous reply as answer is incorrect.
Thanks for the guidance from everyone....but this is not a straight forward area of .net 2.0.
Marked as answer by karlmcauley on Apr 03, 2008 09:44 AM
parms(1) = New ReportParameter("WeekEnding",
New DateTime(2007, 7, 29).ToString())
ReportViewer1.ServerReport.SetParameters(parms)
</div></div></div><div id="1era" class="ArwC7c ckChnd"> </div><div id="1era" class="ArwC7c ckChnd">The call to DateTime.ToString was important to get it into the proper format, which turns out to be dd/mm/yyyy hh:mm:ss. </div>
I was having the same problem listed here and could not get SetParameters to work until I added:
using Microsoft.Reporting.WebForms;
to the top of my code page.
I was getting the "cannot convert from 'Microsoft.Reporting.WinForms.ReportParameter' to 'System.Collections.Generic.IEnumerable<Microsoft.Reporting.WebForms.ReportParameter>" error until then.
I followed other posts that suggested adding the reporting DLLs to the bin directory but that did nothing. In fact I removed them and all my code still works.
I had exactly the same error message : cannot convert string to valid datetime, passing 2 date parameters from a javascript calendar. it worked on the dev server but not on the deployed server.
the deployed server had different date time settings, regional settings. I changed the rdlc report definition parameter to English (US) and it then worked.
You can use any date format in the application. The problem is because of the culture in the report object. ie. when you create a rdlc report, it will select your development pc's culture. that is why not getting error from development pc. So you have to
change the Language option in the report properties to "Default".
sasi.k
Participant
1547 Points
296 Posts
Re: ReportViewer Not Accepting DateTime Parameters
Mar 27, 2008 11:30 AM|LINK
yes am using the date time parameter in reportviewer its working fine for me.i have used like this.
// Setting datetime parameters
ReportParameter endTimeParameter = new ReportParameter(parameterName, fixDateTime(Convert.ToDateTime(txtEndDate.Text), 23, 59, 59).ToString());
this.ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { endTimeParameter });
private static DateTime fixDateTime(DateTime oDateTime, int iHour, int iMinute, int iSecond)
{
return new DateTime(oDateTime.Year, oDateTime.Month, oDateTime.Day, iHour, iMinute, iSecond);
}
Please remember to click "Mark as Answer" on this post if it helped you.
karlmcauley
Member
3 Points
22 Posts
Re: ReportViewer Not Accepting DateTime Parameters
Apr 03, 2008 09:44 AM|LINK
sasi.k.....thanks for the advice but it just did not work for me.
I had to declare the textbox values (populated from calendar control) as strings and then pass them through to the reports procedure which converted them in sql to datetime fields.
This is the only way i could get it to work properly so whoever marked the previous reply as answer is incorrect.
Thanks for the guidance from everyone....but this is not a straight forward area of .net 2.0.
motaweb
Member
2 Points
1 Post
Re: ReportViewer Not Accepting DateTime Parameters
Apr 08, 2008 02:25 PM|LINK
Go to this page : http://msdn2.microsoft.com/en-us/library/microsoft.reporting.winforms.serverreport.setparameters(VS.80).aspx
Work (at last!) fine for me, even with datetime...
reportviewer cast parameters
martyphee
Member
7 Points
10 Posts
Re: ReportViewer Not Accepting DateTime Parameters
May 15, 2008 08:44 PM|LINK
I ran across this same problem. Here is a vb solution I used. I use c#.
<div id="1era" class="ArwC7c ckChnd"> <div> <div>ReportViewer1.ServerReport.ReportServerUrl =
New Uri("http://server/ReportServer$DEV01 ")
ReportViewer1.ServerReport.ReportPath ="/Tempus/Report2"
Dim parms(1) As ReportParameter
parms(0) =New ReportParameter("ScheduleID", "4")
parms(1) = New ReportParameter("WeekEnding", New DateTime(2007, 7, 29).ToString())
ReportViewer1.ServerReport.SetParameters(parms)
</div></div></div><div id="1era" class="ArwC7c ckChnd"> </div><div id="1era" class="ArwC7c ckChnd">The call to DateTime.ToString was important to get it into the proper format, which turns out to be dd/mm/yyyy hh:mm:ss. </div>tundro
Member
2 Points
1 Post
Re: ReportViewer Not Accepting DateTime Parameters
Jul 16, 2008 11:25 PM|LINK
I was having the same problem listed here and could not get SetParameters to work until I added:
using Microsoft.Reporting.WebForms;
to the top of my code page.
I was getting the "cannot convert from 'Microsoft.Reporting.WinForms.ReportParameter' to 'System.Collections.Generic.IEnumerable<Microsoft.Reporting.WebForms.ReportParameter>" error until then.
I followed other posts that suggested adding the reporting DLLs to the bin directory but that did nothing. In fact I removed them and all my code still works.
ma_bi
Member
2 Points
1 Post
Re: ReportViewer Not Accepting DateTime Parameters
Jun 30, 2009 09:34 AM|LINK
I had exactly the same error message : cannot convert string to valid datetime, passing 2 date parameters from a javascript calendar. it worked on the dev server but not on the deployed server.
the deployed server had different date time settings, regional settings. I changed the rdlc report definition parameter to English (US) and it then worked.
http://homepage.bluewin.ch/nmb/
sumithz
Member
2 Points
1 Post
Re: ReportViewer Not Accepting DateTime Parameters
Aug 10, 2010 07:16 AM|LINK
You can use any date format in the application. The problem is because of the culture in the report object. ie. when you create a rdlc report, it will select your development pc's culture. that is why not getting error from development pc. So you have to change the Language option in the report properties to "Default".