无效的报告文件路径 [英] invalid report file path

查看:68
本文介绍了无效的报告文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到错误无效的报告文件路径",下面给出了我的代码,请帮助

i am getting the error "inavalid report file path" my code is given below please help

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

推荐答案

尝试以下语句-

Try the below statement -

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



如果您仍然遇到错误,请告诉我们您存储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.


无效的报告文件路径"
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[^]


这篇关于无效的报告文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆