简体   繁体   中英

how to load .rpt file from specific folder

I am using access database ,and VS2010,I am trying to load crystal report but getting this error for this line ,what is wrong with server how should i write this

rptDoc.Load(Server.MapPath("C:/Users/Monika/Documents/Visual Studio 2010/Projects/SonoRepo/SonoRepo/Report/PatientCrystalReport.rpt")); for server

Code

private void ViewReport_Load(object sender, EventArgs e)
        {
            ReportDocument rptDoc = new ReportDocument();
            PatientDataset ds = new PatientDataset(); // .xsd file name
            DataTable dt = new DataTable();

            // Just set the name of data table
            dt.TableName = "Patient Crystal Report ";
            dt = getAllPatients(); //This function is located below this function
            ds.Tables[0].Merge(dt);


           //getting error here
           // Your .rpt file path will be below

            rptDoc.Load(Server.MapPath("C:/Users/Monika/Documents/Visual Studio 2010/Projects/SonoRepo/SonoRepo/Report/PatientCrystalReport.rpt"));

            //set dataset to the report viewer.
            rptDoc.SetDataSource(ds);
            PatientCrystalReport.ReportSource = rptDoc;
        }

Try it without Server.MapPath :

rptDoc.Load(@"C:\....rpt");

MapPath is intended for use by server-side code in web programming. Since you're using WinForms, it's useless.

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