cancel
Showing results for 
Search instead for 
Did you mean: 

Crystal .NET runtime SP25 and later behave differently setting a parameter value in ASP.NET

michael_dowdie
Explorer
0 Kudos

The ASP.NET code snippet below sets a parameter value using the web .NET Report Viewer. The parameter value is set in the code, so the web report viewer doesn't prompt for the value. This is the desired behavior.

This works properly up to and including SP24. With SP25 and later, the parameter value doesn't stick and the viewer prompts for the parameter as if it wasn't set. Or, if prompting is disabled for the viewer, a "missing parameter value" message results.


Was this change intentional? If not, can it be corrected in a future SP release? Any help or advice is appreciated.

Dim vParmValues As CrystalDecisions.Shared.ParameterValues

Dim vParmDiscreteValue As CrystalDecisions.Shared.ParameterDiscreteValue

Dim vParmField As CrystalDecisions.Shared.ParameterField

vParmValues = New CrystalDecisions.Shared.ParameterValues

vParmDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue

vParmField = CrystalReportViewer.ParameterFieldInfo("My Parameter")

vParmDiscreteValue.Value = "some value"

vParmValues.Add(vParmDiscreteValue)

vParmField.CurrentValues = vParmValues

Thanks,

Michael

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Confirmed it's an issue, works in SP 24 but no higher.

It's been escalated to R&D for a fix in SP 30 due out in early February 2021.

Incident 722601

KBA 2996161

Answers (3)

Answers (3)

Try SP 29, we don't support older runtime since we don't patch this product, full versions only.

There was a change where if the report is based on a Stored Procedure the Parameter value needs to be set before setting the log on info. And you need to specifically search for Subreports and set their log on info now also. We used to Propagate the main report connection to the subreport but not any more, because there is the possibility the subreport uses a different connection.

Be sure the Viewer has the use Parameter value set to false.

You can test if it's a SP this way:

private void SetParam_Click(object sender, EventArgs e)
{
    try
    {
        foreach (CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition pField in (ParameterFieldDefinitions)rpt.DataDefinition.ParameterFields)
        {
            //btnSQLStatement.Text = (dynamic)pField.CurrentValues[0].ToString();
            //if (pField.CurrentValues.Count != 0 || pField.DefaultValues.Count != 0)
            //{
            //}

            if (pField.ParameterType == ParameterType.StoreProcedureParameter)
            {
                if (pField.ReportName == "")
                {
                    if (pField.ParameterFieldName == "@a")
                        SetCrystalParam(rpt, "a", "1");
                }
                if (pField.ReportName == "test")
                {
                    if (pField.ParameterFieldName == "@a")
                        SetCrystalParam(rpt, "a", "0");
                }
            }
            if (pField.ParameterType == ParameterType.ReportParameter)
            {
                if (pField.ParameterFieldName == "CRParam")
                    SetCrystalParam(rpt, "@CRParam", "1003");
                //if (pField.ParameterFieldName == "CRParam")
                //    SetCrystalParam(rpt, "@CRParam", "1004");
            }
        }
    }
    //{
    //    foreach (CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition pField in (ParameterFieldDefinitions)rpt.DataDefinition.ParameterFields)
    //    {
    //        if (pField.ParameterType == ParameterType.StoreProcedureParameter)
    //        {
    //            rpt.SetParameterValue("@test", "1003");
    //        }
    //        if (pField.ParameterType == ParameterType.ReportParameter)
    //        {
    //            if (pField.ParameterFieldName == "test")
    //                rpt.SetParameterValue("test", "1003");


    //            if (pField.ParameterFieldName == "abc")
    //                rpt.SetParameterValue("abc", "3");
    //        }
    //    }
    //}
    catch (Exception ex)
    {
        MessageBox.Show(ex.ToString());
    }
    btnSQLStatement.Text += "\nParameters Set";
}

Don

0 Kudos

Contacted Michael for test app

michael_dowdie
Explorer
0 Kudos

Hi Don,

Thanks very much for the quick response and advice. I'll work toward understanding and trying the code you provided.

Here's what I've done already. I noticed my code stopped working after updating from SP20 to SP28. So, I set up a VM and tested the same simple ASP.NET page with a simple report -- no subreports or stored procedures. I worked my way forward, trying each version from SP20 onward. The code worked fine as it always had up to SP24. It stopped working at SP25. It definitely doesn't work with SP28 or SP29.

I'd like to move to SP29, but this is a bit of a show-stopper for going past SP24. There's far too much code that would break.

If it would be helpful, I can send the small set of files I used to test -- Just a web.config and .aspx with a simple report running against the good old Xtreme sample MDB.

Thanks again and best regards,

Michael

michael_dowdie
Explorer
0 Kudos

Hi,

I've confirmed again that setting a parameter value by way of the report viewer's ParameterFieldInfo does not work after SP24, including in SP29. The same ASP.NET code works all the way up to and including SP24, but is ineffective after SP24. Nothing fancy in the report -- no subreports or stored procedures.

vParmField = CrystalReportViewer.ParameterFieldInfo("My Parameter")

vParmDiscreteValue.Value = "some value"

vParmValues.Add(vParmDiscreteValue)

vParmField.CurrentValues = vParmValues

Thanks,

Michael