Crystal Report using a parameterized Stored Procedure
-
Hi, i don't understand the error i encountered when using a parameterized Stored Procedure in my Crystal report.... below is my coding: using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using CrystalDecisions.CrystalReports.Engine; using CrystalDecisions.Shared; public partial class _Default : System.Web.UI.Page { private ReportDocument CreateCrystalReportDocument() { ReportDocument rpt = new ReportDocument(); string reportPath = Server.MapPath("MyCrReport.rpt"); rpt.Load(reportPath); ConnectionInfo connectionInfo = new ConnectionInfo(); connectionInfo.ServerName = @"MyServer"; connectionInfo.DatabaseName = "MyDatabase"; connectionInfo.UserID = "MyUserId"; connectionInfo.Password = "MyPassword"; Tables tables = rpt.Database.Tables; foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables) { TableLogOnInfo tableLogonInfo = table.LogOnInfo; tableLogonInfo.ConnectionInfo = connectionInfo; table.ApplyLogOnInfo(tableLogonInfo); } ParameterField paramField; ParameterDiscreteValue discreteVal = ParameterDiscreteValue(); //the next line encounters an error occur // 'crystalReportViewer1.ParameterFieldInfo is NULL' paramField = crystalReportViewer1.ParameterFieldInfo["@boardTitle"]; //----------------- //the next line did not encounter error on this line but an //error occur after exiting // this method === error value expected at parameter "@boardTitle" // paramField = rpt.ParameterFieldInfo["@boardTitle"]; discreteVal.Value = "Sample"; paramField.CurrentValues.Add(discreteVal); return rpt; } private void Page_Init(object sender, EventArgs e) { ReportDocument rpt = null; rpt = CreateCrystalReportDocument(null, "ProductName"); CrystalReportViewer1.ReportSource = rpt; } } anybody who can correct my coding.... thank you in advance to those who can help...
xxx