报告rdlc中的外部映像



我将图像上传到服务器并将其路径存储在表(varchar(MAX))中。

我设法创建了一个报告,并显示了该表中的记录,但我无法将图像绑定到它的数据源(存储路径)。

我的路径是这样的:

~/ARTSQLDATA PTDIR/15090248/IDFTO/15090248 ppid.jpg

我使用以下代码填充我的数据集

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Not IsPostBack Then
        RepVuerCtl.ProcessingMode = ProcessingMode.Local
        RepVuerCtl.LocalReport.ReportPath = Server.MapPath("~/Account/RepPtProf.rdlc")
        RepVuerCtl.LocalReport.EnableExternalImages = True
        Dim DsPtProf As DSPtProf = GetData()
        Dim datasource As New ReportDataSource("PatientProfile", DsPtProf.Tables(0))
        RepVuerCtl.LocalReport.DataSources.Clear()
        RepVuerCtl.LocalReport.DataSources.Add(datasource)
    End If
End Sub
Private Function GetData() As DSPtProf
    Dim ARTSQLCON As SqlConnection = New SqlConnection(-------())
    Dim SQLCmd As New SqlCommand()
    SQLCmd.Connection = ARTSQLCON
    Using DtaRdr As New SqlDataAdapter(SQLCmd)
        SQLCmd.CommandType = CommandType.StoredProcedure
        SQLCmd.CommandText = "RepTblRegPtProf"
        SQLCmd.Parameters.Add("@FileNum", SqlDbType.Int).Value = 15090248 
        Using DsPtProf As New DSPtProf()
            DtaRdr.Fill(DsPtProf, "RepTblRegPtProf")
            Return DsPtProf
        End Using
    End Using
End Function

请帮助谢谢!

我找到了一个解决方案,我想和你分享,我很想听到你的反馈,

我修改了我的上传函数,以URI格式保存图像路径(编码)(即. .

Dim ImgURI As String = New Uri(Server.MapPath("URL String")).AbsoluteUri    

要在webform上显示图像,我将URI解码为URL

Function ConvertURI(URI As String)
    Dim DecodeURI As String = HttpUtility.UrlDecode(URI) 'Decode URI string
    Dim SubURI = DecodeURI.Substring(DecodeURI.IndexOf("Your Folder"))
    Dim URL As String = "~/" & SubURI ' Restore the URL string format
    Return URL
End Function
' then in your code
Dim ImgURL as string = ConvertURI("Your URI")
Sampleimg.ImageUrl = ImgURL

要在RDLC报告中显示图像,只需将图像控制源设置为external,并将图像值分配给表中的字段值非常感谢您的反馈。谢谢!

最新更新