Click here to Skip to main content
15,913,486 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
When i creating CrystalReport in C# Windows application i load the data source as
C#
ReportDocument stu = new ReportDocument();
stu.Load("samplereport.rpt");
DataSet ds = objstudent.SelectStudent_report();
stu.SetDataSource(ds.Tables[0]);
crystalReportViewer1.ReportSource = stu;
crystalReportViewer1.Visible = true;
crystalReportViewer1.Enabled = true;

here it give an error as "Load report failed."..
but wen i specifying path as
C#
stu.Load("G:\\ISR\\ISR project\\phase 1\\isr\\isr\\samplereport.rpt");

it will work properly.

how we can load the datasourse without specifing the entire path of the report.



Thank u...
Posted
Updated 5-Sep-12 22:32pm
v3

As my knowladge, you should provide entire path to load report
here is no any shortcut method to specify path.
 
Share this answer
 
Comments
A.Anitha 6-Sep-12 5:02am    
if i give entire path i will create an error when it will execute on another System...
Location (path) must be pass,
and instead of passing it statically you should detect path dynamically.
C#
string rptpath="G:\\ISR\\ISR project\\phase 1\\isr\\isr\\samplereport.rpt";

e.g.
C#
path = System.IO.Path.GetDirectoryName(
      System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase );
string rptpath=path + "\\samplereport.rpt";

Happy Coding!
:)
 
Share this answer
 
Comments
A.Anitha 6-Sep-12 5:18am    
here also am getting same error...
Aarti Meswania 6-Sep-12 5:56am    
it is example when ever you will install application on other pc report path will not same so find it dynamically.
just check 'path' variable value by debugging

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900