Click here to Skip to main content
15,887,083 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i am getting the error "inavalid report file path" my code is given below please help
VB
Dim did As Integer
        Dim d_id As String = Request.QueryString("did")

        'taking d_id value from another web page and convert it to integer
        did = Convert.ToInt32(d_id)
        MsgBox(did)

        Dim con As SqlConnection = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True")
        con.Open()
        Dim cmd As SqlCommand = New SqlCommand("select * from t_donor where d_id=" & did & "", con)
        Dim ds As New DataSet()
        Dim da As SqlDataAdapter = New SqlDataAdapter(cmd)
        da.Fill(ds)

        Dim rptdocument As ReportDocument = New ReportDocument()
        rptdocument.SetDatabaseLogon("Admin","","HLH-PC","Database")

        
        rptdocument.Load(Server.MapPath("Report1.rpt"))
        rptdocument.SetDataSource(ds.Tables(0))
        CrystalReportViewer1.ReportSource = rptdocument
Posted
Comments
[no name] 14-Oct-12 8:43am    
Well.... fix the path to your report.
Aysha Patel 15-Oct-12 6:23am    
Check out where exactly your report file reside...if its in any folder then also give folder name too.like
rd.Load(Server.MapPath("yorfoldename/Report1.rpt"));

Try the below statement -

C#
rptdocument.Load(Server.MapPath("~\Report1.rpt"))


In case you are still getting an error, let us know the path where you have stored the Report1.rpt file as well as the page location where you are trying to access the report from.
 
Share this answer
 
v2
Comments
Sandeep Mewara 14-Oct-12 10:59am    
OP's comment:
till getting same error
please help
Nitesh Kejriwal 15-Oct-12 0:20am    
@Sandeep, Not sure why this comment for me?
Sandeep Mewara 15-Oct-12 0:56am    
He posted the above comment as an answer.

Few people like me who have this power to delete answers (that are not actually an answer), post the related text at appropriate place and remove the answer.

Above text was a comment to your answer posted as an answer so I removed the answer and shared the comment with you.
Nitesh Kejriwal 15-Oct-12 1:27am    
Thanks Sandeep for the explanation! :)
Sandeep Mewara 15-Oct-12 12:47pm    
Welcome.
inavalid report file path"
C#
rptdocument.Load(Server.MapPath("Report1.rpt"))
must be raising this error.

It clearly is relative path issue. You would need to make sure that the path is correct such that file is found and used.

I would suggest you to use this Tip and resolve the path correctly before setting the source: Resolving Paths in a Multi-Folder WebSite[^]
 
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