Click here to Skip to main content
15,881,281 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more: , +
I am passing datetime from textbox (on button click) and passing it to the crystal report:

Code:

C#
ReportDocument cryRpt = new ReportDocument();
      cryRpt.Load("E:\\Developing\\ReportsDB\\CrystalReport4.rpt");
      DateTime datefilter = Convert.ToDateTime(TextBox1.Text);
      cryRpt.SetParameterValue("orderdated", datefilter);
      CrystalReportViewer1.ReportSource = cryRpt;


Error:
C#
A string is required here. Details: errorKind Error in File CrystalReport4 {AA07EFE4-73A5-4C0A-9198-1AEFCD0CB55F}.rpt: Error in formula Record_Selection: '{Command.date} = {?orderdated}' A string is required here. Details: errorKind  



I have filtered by Name(String) but for Date it is giving this Error.
Posted
Updated 10-Sep-14 4:22am
v2

I think you need to pass a string, and not a DateTime object.

Try this,

C#
// take it as a string, 
string datefilter = TextBox1.Text;
// pass it, 
cryRpt.SetParameterValue("orderdated", datefilter);
 
Share this answer
 
I have solved it, i was making mistake while writing formula in crystal report:
it is now :
{Command.date} = {?Orderdate}
and correct.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900