sheen, it might help you to help yourself and also your peers here at forums.asp.net to help you if you would walk your code line by line in the debugger* and show us the relevant values that are related to your code snippet ... also, please show
us the full stack trace.
search videos at Google with debug visual studio 2010
B-) Gerry Lowry, Chief Training Architect, Paradigm Mentors Learning never ends... +1 705-999-9195 wasaga beach, ontario canada TIMTOWTDI =.there is more than one way to do it
In above code I assume that report folder directly inside your root folder. If you have some more folder then add that also just before the reports folder.
let me know if doesn't works.
Member
84 Points
591 Posts
Invalid report file path
Mar 03, 2012 02:39 AM|sheen_buhay|LINK
Hi.
I am trying to export my crystal report to PDF however it gives me an error "Invalid report file path".
Here's the snippet:
protected void btntest_Click(object sender, EventArgs e)
{
ReportDocument rptDocmnt = new ReportDocument();
TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
Tables CrTables;
try
{
crConnectionInfo.ServerName = "192.168.0.246";
crConnectionInfo.DatabaseName = "DB_CRITH";
crConnectionInfo.UserID = "sa";
crConnectionInfo.Password = "123456";
CrTables = rptDocmnt.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
crtableLogoninfo = CrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
CrTable.ApplyLogOnInfo(crtableLogoninfo);
}
string strRptLoad = Server.MapPath("../Reports/PayDetails.rpt");
rptDocmnt.Load(strRptLoad);
BinaryReader stream = new BinaryReader(rptDocmnt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat));
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=payment.pdf");
Response.AddHeader("content-length", stream.BaseStream.Length.ToString());
Response.BinaryWrite(stream.ReadBytes(Convert.ToInt32(stream.BaseStream.Length)));
Response.Flush();
Response.Close();
//crvPay.ReportSource = rptDoc;
}
catch (Exception ex)
{
MsBx(ex.Message);
}
}
The report path is located at "../Reports/PayDetails.rpt" however could not figure it out what went wrong. Please help. Thanks.
sheenb
Member
462 Points
225 Posts
Re: Invalid report file path
Mar 03, 2012 03:06 AM|Mahesh Darkunde|LINK
write like
string strRptLoad = Server.MapPath("..\\Reports\\PayDetails.rpt");
now it can be work..
try this.
Member
84 Points
591 Posts
Re: Invalid report file path
Mar 03, 2012 03:17 AM|sheen_buhay|LINK
@Mahesh,
I appreciate your time looking into my concern, I've tried your idea however it's not working as well.
Please help. Thanks.
sheenb
Star
14297 Points
5797 Posts
Re: Invalid report file path
Mar 03, 2012 05:39 AM|gerrylowry|LINK
@ sheen_buhay
sheen, it might help you to help yourself and also your peers here at forums.asp.net to help you if you would walk your code line by line in the debugger* and show us the relevant values that are related to your code snippet ... also, please show us the full stack trace.
g.
* walking your code with your debugger:
video, c. 8 minutes: http://msdn.microsoft.com/en-ca/vstudio/ee672313.aspx
"How Do I: Step with The Debugger in Visual Studio?"
Debugging: http://lmgtfy.com/?q=debug+visual+studio+2010
example: http://www.codeproject.com/KB/cs/MasteringInDebugging.aspx
videos: http://www.youtube.com/watch?v=z5gBIizwsY0
search videos at Google with debug visual studio 2010
Member
710 Points
202 Posts
Re: Invalid report file path
Mar 03, 2012 08:18 AM|asheejtk|LINK
Hi,
It is sure that your path is not correct so let's try with different option.
In above code I assume that report folder directly inside your root folder. If you have some more folder then add that also just before the reports folder.
let me know if doesn't works.
Asheej T K
Dotnet Galaxy