简体   繁体   中英

Load Report Failed…crystal report error

public void Reports(string query, CrystalReportViewer crystalReportViewer1, string tblname, string rptname)
{
    con.Close();

    try {

        ReportDocument Report = new ReportDocument();
        con.Open();
        SqlDataAdapter da = new SqlDataAdapter(query, con);
        DataSet ds = new DataSet();
        //ds.Tables.Add("Customer_Transaction_Master");
        da.Fill(ds, tblname);
        // Report.Load(System.Windows.Forms.Application.StartupPath + "\\Reports" + rptname);
        Report.Load(Application.StartupPath + "\\Reports" + rptname);
        Report.SetDataSource(ds.Tables[tblname]);
        Report.Refresh();
        crystalReportViewer1.ReportSource = Report;
        crystalReportViewer1.RefreshReport();                      
        Report.PrintOptions.PaperOrientation = PaperOrientation.Portrait;
        Report.PrintOptions.PaperSize = PaperSize.PaperA4;
        Report.PrintToPrinter(1, false, 0, 15);
        Report.Close();
    }
    catch(Exception ex)
    {
        MessageBox.Show(ex.Message);
        //throw ex;

    }
    finally
    {
        con.Close();
    }
}

***********--------- button click--------******

try
{
    frmdailyreport frdp = new frmdailyreport();
    gd.Reports("select * from tbl_bill where date='" + dailydate.Text + "' ", frdp.dailycrystal, "tbl_bill", "//daily.rpt");
    frdp.Show();
}
catch (Exception ex)
{
    MessageBox.Show(ex.Source);
    MessageBox.Show(ex.Message);
}
  • I check the path
  • The permission also given]
  • temp folder has full user control permission

but still load report failed... the thing is that, when i click on button it shows a "Load Report Failed error" and after clicking on "Ok" it shows the crystal report viewer not showing the report.

The globe.cs is my class file and the object of this class file is "gd".

Thank You.

Load Report Error means the report is not found which means definitely the path is wrong, put the exact path of your report within report ie Report.Load("C:\\\\Program Files\\Reports\\dailyReport.rpt"); if it loads it means you are giving wrong path by using Application.Startup, re-verify the path and put your report loading code within your button click just for testing and comment here whether your issue is resolved or not.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM