Crystal Report in Visual Studio web application throws 'Prompting information is missing' error

0

I am creating a report in a c# mvc web application in Visual Studio 2019 with Crystal Reports. The report has 6 subreports, each using the same parameter as the main report ['billId']. The report runs just fine locally and on our Dev server, both of which connect to the same database server, as defined in the .rpt file. However, when I deployed to our Test environment, with a different database server, it of course failed to connect. We're using integrated security.

I then added code to loop through all tables and subreports (and their associated tables) to designate the database server and logon info for each programmatically. This appears to work when I step through the code, but eventually throws a 'Prompting information is missing' error sometime after passing all our code.

The only suggestion I found on the SAP support site is to 'update the subreport links.' Those links all appear fine, or I just don't understand what 'update the subreport links' really means.

Here is our code block:

var conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
var connectionInfo = new ConnectionInfo();
connectionInfo.ServerName = conn.DataSource;
connectionInfo.DatabaseName = "OurDatabaseName";
connectionInfo.IntegratedSecurity = true;
connectionInfo.Type = ConnectionInfoType.SQL;

if (Request.QueryString["billId"] != null)
{
    var reportName = Request.QueryString["reportName"];
    var billId = Int32.Parse(Request.QueryString["billId"]);
    ReportDocument rd = new ReportDocument();
    string path = Server.MapPath("~") + "Reports//" + reportName;
    rd.Load(path);
    rd.SetParameterValue("billId", billId);

    TableLogOnInfo crTableLogOnInfo = new TableLogOnInfo();
    Tables crTables = rd.Database.Tables;
    foreach (Table crTable in crTables)
    {
        crTableLogOnInfo = crTable.LogOnInfo;
        crTableLogOnInfo.ConnectionInfo = connectionInfo;
        crTable.ApplyLogOnInfo(crTableLogOnInfo);
    }

    foreach (ReportDocument crSubReport in rd.Subreports)
    {
        foreach (Table crSubTable in crSubReport.Database.Tables)
        {
            TableLogOnInfo crSubTableLogOnInfo = crSubTable.LogOnInfo;
            crSubTableLogOnInfo.ConnectionInfo = connectionInfo;
            crSubTable.ApplyLogOnInfo(crSubTableLogOnInfo);
        }
        rd.SetParameterValue("billId", billId, crSubReport.Name.ToString());
    }
}

CrystalReportViewer1.RefreshReport();
CrystalReportViewer1.ReportSource = rd;
CrystalReportViewer1.EnableDatabaseLogonPrompt = false;

Resulting Stack Trace:

[COMException (0x80004005): Prompting information is missing.]
   CrystalDecisions.ReportAppServer.Prompting.IPromptEngine.startPrompting(PromptingUnits units, CRPromptingInfoProvider infoProvider, PromptingOption option) +0
   CrystalDecisions.ReportSource.EromReportSourceBase.DoParameterPrompting(PromptingRequestContext reqContext) +601
   CrystalDecisions.CrystalReports.Engine.FormatEngine.DoParameterPrompting(PromptingRequestContext reqContext) +44
   CrystalDecisions.ReportSource.LocalReportSourceBase.DoParameterPrompting(PromptingRequestContext reqContext) +155
   CrystalDecisions.Web.ReportClosedExceptionHandlingReportSource.DoParameterPrompting(PromptingRequestContext reqContext) +41
   CrystalDecisions.Web.ReportAgentBase.DoPrompting(PromptingHTMLRenderOption htmlOption) +105
   CrystalDecisions.Web.Components.ParamComponent.ShowFullPrompt() +62
   CrystalDecisions.Web.Components.ParamComponentBase.HandleException(Exception e) +58
   CrystalDecisions.Web.CrystalReportViewer.HandleExceptionAndPromptIfNeeded(Exception x, EnumAspNetLifeCycleStage stage) +297
   CrystalDecisions.Web.CrystalReportViewer.OnPreRender(EventArgs e) +106
   System.Web.UI.Control.PreRenderRecursiveInternal() +166
   System.Web.UI.Control.PreRenderRecursiveInternal() +236
   System.Web.UI.Control.PreRenderRecursiveInternal() +236
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4714

Any thoughts or other code patterns known to work would be greatly appreciated! THX.

c#
visual-studio
model-view-controller
crystal-reports
asked on Stack Overflow Aug 25, 2020 by Stan

1 Answer

0

This issue has been resolved.

Our Local dev machines had installed Crystal for Visual Studio via CRforVS13SP27_0-10010309.EXE

We installed the latest version, CRforVS13SP28_0-10010309.EXE. After a reboot, this resolved the 'Prompting information is missing' error.

Subsequently, we removed this line of code:

CrystalReportViewer1.RefreshReport();

which fixed a follow-on issue where the report was prompting for billID.

answered on Stack Overflow Aug 26, 2020 by Stan

User contributions licensed under CC BY-SA 3.0