Greetings from Appdev (i'm new to Crystall Report)
I was Creating a web application which will contains a crystal report.
My Requirement is:
The report should be displayed Based on the value (textbox in web form) which is given in textbox.
Eg: if Textbox value = 2 means only the item which has id 2 should only get display.
My crystal report has 3 different table like cheque,Party and finally bank. these 3 tables are linked by 1 common field called id.
need to know how to pass parameter(id) to crystal report.
while seeing the preview it was displaying properly.
but i dnt know how to send id from .cs to crystal report.
this is how i bind the crystal report using parameters from .cs file in c#
public void LoadTransReceipt()
{
string Date = "";
string Sql = "SELECT tREC_NUPKId as ID from TB_TransReceipt where tREC_VCVoucherNo='" + TXTVou.Text.Trim() + "' and tREC_NUIsActive=1";
SqlDataReader rdr = mobjGenlib.objDBLib.ExecuteQueryReader(Sql.ToString());
while (rdr.Read())
{
Session["ID"] = rdr.GetValue(0).ToString();
}
rdr.Close();
if (!string.IsNullOrEmpty(Session["ID"] as string))
{
if (Session["Date"] != null)
{
Date = mobjGenlib.ConvertString(Session["Date"]);
}
reportPath = GetReportPath("TransReceipt.rpt");
CRReport = new ReportDocument();
CRReport.Load(reportPath);
CrystalReportViewer1.ReportSource = CRReport;
ParameterFieldDefinitions crParameterFieldDefinitions;
ParameterFieldDefinition crParameterFieldDefinition;
ParameterValues crParameterValues = new ParameterValues();
ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();
crParameterDiscreteValue.Value = Session["ID"];
crParameterFieldDefinitions = CRReport.DataDefinition.ParameterFields;
crParameterFieldDefinition = crParameterFieldDefinitions["IDP"];
crParameterValues = crParameterFieldDefinition.CurrentValues;
crParameterValues.Clear();
crParameterValues.Add(crParameterDiscreteValue);
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
CrystalReportViewer1.ReportSource = CRReport;
CrystalReportViewer1.RefreshReport();
ConnectionInfo objConnInfo = new ConnectionInfo();
objConnInfo.DatabaseName = "Demo";
objConnInfo.UserID = "sa";
objConnInfo.Password = "xxx";
objConnInfo.ServerName = "HOME-PC\\SQLEXPRESS";
SetDBLogonForReport(objConnInfo, CRReport);
SetDataSetForMultipleSubReport(objConnInfo, CRReport);
}
}
and this is the line i'm getting error
crParameterFieldDefinition = crParameterFieldDefinitions["IDP"];
can any one help to resolve this.
Thanks in advance