SAP Knowledge Base Article - Public

2042524 - Error : "InvalidCastException: Specified cast is not valid".


  • A Crystal Reports .NET windows application to view a Crystal report, fails with below error when user clicks on the 'Date Time picker' (calendar icon) from viewer's parameter panel.

Error : "InvalidCastException: Specified cast is not valid".

  • The report contains a 'Date' type parameter.
  • The parameter value is passed through code.


  • SAP Crystal Reports developer version for Microsoft Visual Studio.
  • Visual Studio 2010

Reproducing the Issue

1. Design Crystal report with a date parameter.
2. Use below code and develop a sample windows application.

CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); 
rpt.SetParameterValue("My Parameter", "12/3/2010");
crystalReportViewer1.ReportSource = rpt;

3. Run the application.
4. Once the report is viewed, view parameter panel and click the 'Date time picker' (calendar button).


Below code is passing the date value as a string and the parameter panel is not able to cast a string into date implicitly.

rpt.SetParameterValue("My Parameter", "12/3/2010");


While passing the parameter value, cast it to Date type explicitly.

rpt.SetParameterValue("My Parameter", Convert.ToDateTime("12/3/2010"));


KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem


SAP Crystal Reports, developer version for Microsoft Visual Studio