DateTime parameter passing problem to Crystal Report in VS2005



    Hi All,


    I am using CR of VS2005 (.NET 2.0 framework). Well i have already a code which works fine on VS2002 i.e .Net FrameWork 1.0. But when i ported to VS2005, the DateTime fields in the CR which are being passes as parameter values are showing a parameter enter window before displaying the report screen.


    I the code which is used to pass the Date Time as a parmeter is as show below:


    Code Block

    ParameterFields paramFields = new ParameterFields ();

    ParameterField paramField1 = new ParameterField ();

    ParameterDiscreteValue discreteVal1 = new ParameterDiscreteValue ();

    paramField1.ParameterFieldName = "StartDate";

    discreteVal1.Value = StartDate.ToLongDateString();

    paramField1.CurrentValues.Add (discreteVal1);


    paramFields.Add (paramField1);



    I saw the output of the DateTime parameter using the MessageBox as shown in the code. The format was like: Friday, January 04, 2008.


    I changed the format of Date field (parameter firelds) in CR under Edit Parameter Field window to DateTime Value type. Still its not accepting the values. I changed the above code higlited ToLongDateString() method to ToShortDateString(), ToUniversalTime(), ToString() methods too. But none are helping me to show the user selected Date on the GUI window. Oh btw, i am allowing Discrete Values for that Date fields.


    So what should i do to get the Date displayed properly on CR ? The same report and code works charming on VS2002 with out asking for any Parameter window kinda thing.


    Please help me.



    Thursday, January 17, 2008 4:35 AM

All replies