4

This code runs perfectly on my computer, but causes error on client's computer.

cr.SetParameterValue("fromDate", fromDatePicker.Value.Date);
cr.SetParameterValue("toDate", toDatePicker.Value.Date);
cr.SetParameterValue("todayRate", Common.GetTodayRate());

The Error is

Invalid Parameter value: exceeds the Min or Max or conflicts with existing value or edit mask

here, fromDate & toDate are of 'Date' type parameters. while todayRate is of 'Number' type Parameter.

Any way to resolve this issue?

2
  • Well given the parameters have the same values, instant suspicion is something to do with a difference between their culture (date and number settings) and yours. CR isn't something I use, are the parameters typed on the CR side. If they were getting converted to strings that would pretty much guarantee an error like this Sep 15, 2013 at 13:37
  • A stack trace (this is an exception?) might tell you more Sep 15, 2013 at 13:39

1 Answer 1

0

The issue is related to culture-sensitive processing of parameter inputs from your application code to CR. CR is apparently badly designed when it comes to multi-lingual support in specific situations such is this one.

The solution, albeit ugly, is as follows.

For each Date, Time or DateTime parameter field that you have in your report, do the following:

  1. Within CR designer, change the type of the parameter field to String.
  2. Create a new formula field and set its value to one of the following:

    CDate({?ParamFieldName}) // Date
    CTime({?ParamFieldName}) // Time
    CDateTime({?ParamFieldName}) // DateTime
    

    depending on the original parameter field type, where ParamFieldName is the name of your parameter field.

  3. In your application code, pass the parameter value in one of the following ways:

    // Date
    report.SetParameterValue(
        "ParamFieldName",
        DateTimeObject.ToShortDateString().TrimEnd('.'));
    
    // Time
    report.SetParameterValue(
        "ParamFieldName",
        DateTimeObject.ToShortTimeString());
    
    // DateTime
    report.SetParameterValue(
        "ParamFieldName",
        string.Format("{0} {1}",
            DateTimeObject.ToShortDateString().TrimEnd('.'),
            DateTimeObject.ToShortTimeString()));
    
  4. Within CR designer, insert formula fields instead of parameter fields and format their display within CR designer.

This has been tested on several cultures.

The ending dot in date string is being trimmed because CR, for unknown reasons, cannot process the dot, even on cultures that have the dot at the end of the dates (ie. Serbian - 14.3.2015.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.