magesh manavalan

magesh manavalan

  • 1.1k
  • 331
  • 499.6k

Error Shows Object Reference not set to an instance of object

Nov 3 2012 7:35 AM
            con = new SqlConnection("Server=(local);initial catalog=ServiceTax;Trusted_Connection=True");
            con.Open();
            string str = "select * from Service where Billno='" + textBox1.Text+ "'";
            SqlCommand com = new SqlCommand(str, con);
            SqlDataAdapter sqlda = new SqlDataAdapter(com);
            DataSet ds = new DataSet();
            sqlda.Fill(ds, "Service");
            con.Close();

            ReportDocument RptDoc = new ReportDocument();
            HttpContext.Current.Server.MapPath("Reports/SReport.rpt");
            RptDoc.SetDataSource(ds);
            crystalReportViewer1.ReportSource = RptDoc;
            crystalReportViewer1.RefreshReport();
        

In run mode i have one text box and Button in that button i type a partiuclar bill no that data to be displayed.when i type the particular bill no an dick that button Error Shows as Object Reference not set to an instance of object.

In this line  HttpContext.Current.Server.MapPath("Reports/SReport.rpt");  [Object Reference not set to an instance of object]