Click here to Skip to main content
15,903,203 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to know how to create crystal report for different machine names in c#


ReportDocument cryRpt = new ReportDocument();
cryRpt.Load(@"C:\Documents and Settings\Arusha\My Documents\Visual Studio 2008\Projects\Schooll salary system\Schooll salary system\rpt_empdataall.rpt");
crystalReportViewer1.ReportSource = cryRpt;
crystalReportViewer1.Refresh();



here "Arusha" is my matchine name and also path of location c: is different for onother machine so i can't genarate reports after intalling another machine. plz give me solution for this.
Posted
Updated 7-May-11 22:56pm
v2
Comments
OriginalGriff 8-May-11 4:15am    
Pardon? What is your question? Please use the "Improve question" widget and give more information.
Prabodhapsb 8-May-11 6:19am    
i want to know how to create crystal report for different machine names in c#


ReportDocument cryRpt = new ReportDocument();
cryRpt.Load(@"C:\Documents and Settings\Arusha\My Documents\Visual Studio 2008\Projects\Schooll salary system\Schooll salary system\rpt_empdataall.rpt");
crystalReportViewer1.ReportSource = cryRpt;
crystalReportViewer1.Refresh();



here "Arusha" is my matchine name and also path of location c: is different for onother machine so i can't genarate reports after intalling another machine. plz give me solution for this.
Sandeep Mewara 8-May-11 4:22am    
You "wanna" what?

Avoid text speak - you are on a professional forum.
Prabodhapsb 8-May-11 6:20am    
i want to know how to create crystal report for different machine names in c#


ReportDocument cryRpt = new ReportDocument();
cryRpt.Load(@"C:\Documents and Settings\Arusha\My Documents\Visual Studio 2008\Projects\Schooll salary system\Schooll salary system\rpt_empdataall.rpt");
crystalReportViewer1.ReportSource = cryRpt;
crystalReportViewer1.Refresh();



here "Arusha" is my matchine name and also path of location c: is different for onother machine so i can't genarate reports after intalling another machine. plz give me solution for this.

It's pretty simple. Your mistake is that you are hard-coding an absolute path. Use relative path. Put the crystal report in the application folder and then access it using relative path of that folder. This way, where-ever you have your application installed, the crystal report too would be delivered at a fixed path and thus accessible.
 
Share this answer
 
Comments
Prabodhapsb 8-May-11 8:18am    
thanks, it's working.
Sandeep Mewara 8-May-11 8:21am    
Good to know! :thumbsup:
Use relative paths. For instance
C#
string myBasePath = System.IO.Path.GetDirectoryName(Application.ExecutablePath);

Take this as ground 0 and find other sources relative to this path.
If a report is in a directory named "Reports" next to your executable then
you can just use
myBasePath+"\\Reports\\rpt_empdataall.rpt"
in your case since report is located 2 level above executable
myBasePath+"\\..\\..\\rpt_empdataall.rpt"
would suffice.
I hope that is what you are trying to achieve.
 
Share this answer
 

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