I have a codes and it is working properly. The only problem is at the top of my page I always having this error message, "Object Reference not set to an instance of an object". I can't find where is the cause of the error message. Any help? Thanks in advance.
Here's my codes:
connect.Open();
ReportDocument report;
ParameterFields pFields = null;
ParameterField pfMonth = null;
ParameterField pfYear = null;
ParameterDiscreteValue valueMonth = null;
ParameterDiscreteValue valueYear = null;
DataSet ds = (DataSet)Session["dataset"];
try
{
pFields = new ParameterFields();
pfMonth = new ParameterField();
pfYear = new ParameterField();
valueMonth = new ParameterDiscreteValue();
valueYear = new ParameterDiscreteValue();
valueMonth.Value = Session["month"].ToString();
valueYear.Value = Session["year"].ToString();
pfMonth.Name = "month";
pfYear.Name = "year";
pfMonth.CurrentValues.Add(valueMonth);
pfYear.CurrentValues.Add(valueYear);
pFields.Add(pfMonth);
pFields.Add(pfYear);
crview.ParameterFieldInfo = pFields;
crview.RefreshReport();
report = new ReportDocument();
report.Load(Server.MapPath("cdrMonth.rpt"));
report.SetDataSource(ds.Tables[0]);
report.Refresh();
crview.ReportSource = report;
crview.DataBind();
lblError.Visible = false;
}
catch (Exception ex)
{
lblError.Text = ex.Message;
lblError.Visible = true;
}
finally
{
if (ds != null)
{
ds.Dispose();
ds = null;
}
pFields = null;
pfMonth = null;
pfYear = null;
valueMonth = null;
valueYear = null;
connect.Close();
}

New Topic/Question
Reply




MultiQuote



|