The way I load a report is as follows - this always works for me regardless if the parameters are Crystal or due to an underlying stored procedure;
using(ReportDocument crReport = new ReportDocument())
{
crReport.Load("Path and file name");
if(crReport.DataDefintion.ParameterFields.Count > 0)
{
foreach(ParameterFieldDefintion crDef in crReport.DataDefinition.ParameterFields)
{
if(crDef.ReportName == string.Empty)
{
crReport.SetParameterValue(crDef.ParameterFieldName, "myvalue");
}
}
}
ConnectionInfo crConn = new ConnectionInfo();
crConn.ServerName = "myServer";
crConn.DatabaseName = "myDbName";
crConn.UserID = "myUserName";
crConn.Password = "myPassword";
Tables crTables = crReport.Database.Tables;
for(int i = 0; i < crTables.Count; i++)
{
Table crTable = crTables[i];
TableLogOnInfo tblInfo = crTable.LogOnInfo;
tblInfo.ConnectionInfo = crConn;
crTable.ApplyLogOnInfo(tblInfo);
}
if(crReport.Subreports.Count > 0)
{
for(int i = 0; i < crReports.Subreports.Count; i++)
{
using(ReportDocument crSub = crReport.OpenSubReport(crReport.Subreports[i].Name)
{
Tables crSubTables = crSub.Database.Tables;
for (int ii = 0; ii < crSubTables.Count; ii++)
{
Table crSubTable = crSubTables[i];
TableLogOnInfo tblSInfo = crSubTable.LogOnInfo;
tblSInfo.ConnectionInfo = crConn;
crSubTable.ApplyLogOnInfo(tblSInfo);
}
crSub.Close();
}
}
}
}
this.crystalReportViewMain.ReportSource = crReport;
If I uncomment the last line I get the behavior you describe in that the Report then prompts me to re-enter the parameter values
Really hope this helps you
Kind Regards