Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal Reports with subreports on the web display an error

Status
Not open for further replies.

PawelTru

Programmer
Jul 18, 2002
24
0
0
US
I am trying to post some of my reports on the web and they work fine if the reports do not have subreport. When I have a report with a subreport I getting the following error:
Missing prompting unit.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Missing prompting unit.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[COMException (0x80004005): Missing prompting unit.]
CrystalDecisions.ReportAppServer.Prompting.IPromptEngine.startPrompting(PromptingUnits units, CRPromptingInfoProvider infoProvider, PromptingOption option) +0
CrystalDecisions.ReportSource.EromReportSourceBase.DoParameterPrompting(PromptingRequestContext reqContext)
CrystalDecisions.CrystalReports.Engine.FormatEngine.DoParameterPrompting(PromptingRequestContext reqContext)
CrystalDecisions.ReportSource.LocalReportSourceBase.DoParameterPrompting(PromptingRequestContext reqContext)
CrystalDecisions.Web.ReportAgentBase.)(PromptingHTMLRenderOption r)
CrystalDecisions.Web.CrystalReportViewer.OnPreRender(EventArgs e)
System.Web.UI.Control.PreRenderRecursiveInternal()
System.Web.UI.Control.PreRenderRecursiveInternal()
System.Web.UI.Control.PreRenderRecursiveInternal()
System.Web.UI.Page.ProcessRequestMain()

The code does login for each subreport and collects the parameters.

Here is the code for parameter collection:
// get the parameter field definitions
ParameterFieldDefinitions crParamFieldDefinitions = report.DataDefinition.ParameterFields;

// for each parameter, get the value from the control
foreach (CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition def in crParamFieldDefinitions)
{
// get parameter name
string paramName = def.ParameterFieldName;

// get the param type
CrystalDecisions.Shared.ParameterValueKind kind = def.ParameterValueKind;

// find the control with that name as its id
Control currentControl = FindControl(paramName);

if (currentControl == null)
currentControl = FindControl(paramName + "!True");


string currentValue = "";
if(currentControl!=null) // if you got the control
{
// switch on the type to cast the control
switch (kind)
{
case CrystalDecisions.Shared.ParameterValueKind.DateParameter:
case CrystalDecisions.Shared.ParameterValueKind.DateTimeParameter:
VSJCustomControlLibrary.VSJDateControl vsjDate =
(VSJCustomControlLibrary.VSJDateControl) currentControl;
currentValue = vsjDate.DateString;
break;

case CrystalDecisions.Shared.ParameterValueKind.CurrencyParameter:
case CrystalDecisions.Shared.ParameterValueKind.StringParameter:
case CrystalDecisions.Shared.ParameterValueKind.TimeParameter:
case CrystalDecisions.Shared.ParameterValueKind.NumberParameter:
DropDownList ddList = (DropDownList) currentControl;
currentValue = ddList.SelectedValue.ToString();
break;
case CrystalDecisions.Shared.ParameterValueKind.BooleanParameter:
System.Web.UI.WebControls.RadioButton rb = (RadioButton) currentControl;
currentValue = rb.Checked.ToString();
break;
} // end switch
} // end if currentControl != null


// create new Parameter Discrete Value object
CrystalDecisions.Shared.ParameterDiscreteValue crParamDiscreteValue = new CrystalDecisions.Shared.ParameterDiscreteValue();

// Set the value of the Discrete value object
crParamDiscreteValue.Value = currentValue;

// extract the collection of current values
CrystalDecisions.Shared.ParameterValues crCurrentValues = def.CurrentValues;
//crCurrentValues.re
// Add the Discrete value object to the collection
// of current values
crCurrentValues.Add(crParamDiscreteValue);
//ParameterField parameter
// apply the modified current values to the param collection
def.ApplyCurrentValues(crCurrentValues);

}

Here is my code for logon for each report:
CrystalDecisions.CrystalReports.Engine.ReportDocument crDoc =
(CrystalDecisions.CrystalReports.Engine.ReportDocument) Session["report"];

CrystalDecisions.Shared.ConnectionInfo ci;
ci = new CrystalDecisions.Shared.ConnectionInfo();

ci.ServerName = servername;
ci.DatabaseName = KHH_Customer_Care;
ci.UserID = uid;
ci.Password = pwd;

//crDoc.Load(Session["report"].ToString());
CrystalDecisions.Shared.TableLogOnInfo tliCurrent;

foreach(CrystalDecisions.CrystalReports.Engine.Table tbl in crDoc.Database.Tables)
{
tliCurrent = tbl.LogOnInfo;
tliCurrent.ConnectionInfo = ci;
tbl.ApplyLogOnInfo(tliCurrent);
}

// Declare a subreport object.
CrystalDecisions.CrystalReports.Engine.SubreportObject subobj;

// Loop through all the report objects and locate subreports.
// If a subreport is found then apply logon information to
// the subreport.
foreach (CrystalDecisions.CrystalReports.Engine.ReportObject obj in crDoc.ReportDefinition.ReportObjects)
{
if (obj.Kind == CrystalDecisions.Shared.ReportObjectKind.SubreportObject)
{
subobj = (CrystalDecisions.CrystalReports.Engine.SubreportObject) obj;

CrystalDecisions.Shared.TableLogOnInfo tliCurrentSub;

foreach(CrystalDecisions.CrystalReports.Engine.Table tbl in crDoc.OpenSubreport(subobj.SubreportName).Database.Tables)
{
tliCurrentSub = tbl.LogOnInfo;
tliCurrentSub.ConnectionInfo = ci;
tbl.ApplyLogOnInfo(tliCurrentSub);
}

}
}

crViewer.ReportSource = crDoc;


Thank You for all your help
 
In the main report create a dummy blank column and add it to the detail section along with the sub report. This will make it work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top