المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Crystal report subreport error...



C# Programming
09-11-2009, 01:24 PM
I'm currently using VS2005 Crystal report... I cant pass the parameter from Main report to its sub report.... it always encounter an error "@pParameter" value expected

I can successfully display a crystal report with parameters but it will fail when it involves subreports.... I don't understand also why I cant display the above parameter but i noticed it runs successfully because it will display the expected output...

hope to here some1 who can share thier ideas..

Thank you

below is the code:

string reportName = Session["ReportName"].ToString();
string reportDate = Session["ReportDate"].ToString();
string reportType = Session["ReportType"].ToString();

rpt.Load(Server.MapPath("~/Reports/" + reportName.ToString()));

crConnectionInfo.ServerName = Session["MyServer"].ToString();
crConnectionInfo.DatabaseName = Session["myDatabase"].ToString();
crConnectionInfo.UserID = "myUser";
crConnectionInfo.Password = "myPassword";

crDatabase = rpt.Database;
crTables = crDatabase.Tables;


CrystalReportViewer1.ReportSource = rpt;

ParameterDiscreteValue discreteBranch = new ParameterDiscreteValue();
ParameterFields paramFields = new ParameterFields();

ParameterDiscreteValue paramDiscreteBranch = new ParameterDiscreteValue();
ParameterField paramFieldBranch = new ParameterField();
paramFieldBranch.Name = "@pBranchCode";
paramDiscreteBranch.Value = Session["branchCode"].ToString();
paramFieldBranch.CurrentValues.Add(paramDiscreteBranch);
paramFields.Add(paramFieldBranch);

ParameterDiscreteValue paramDiscreteTranDate = new ParameterDiscreteValue();
ParameterField paramFieldTranDate = new ParameterField();
paramFieldTranDate.Name = "@pTransactionDate";
paramDiscreteTranDate.Value = reportDate;
paramFieldTranDate.CurrentValues.Add(paramDiscreteTranDate);
paramFields.Add(paramFieldTranDate);

CrystalReportViewer1.ParameterFieldInfo = paramFields;

discreteBranch.Value = Session["branchName"].ToString();
rpt.SetParameterValue("BranchName", discreteBranch);
discreteBranch.Value = Session["branchaddress"].ToString();
rpt.SetParameterValue("BranchAddress", discreteBranch);

xxx