Jump to content
Sign in to follow this  
samesdavis

[Resolvido] Inserir imagem externa dinamicamente no ReportViewer

Recommended Posts

samesdavis

Tenho uma base de dados onde eu guardo os dados do funcionários.

Criei um relatório que irá conter a foto desse funcionário que fica na mesma pasta da base de dados.

No arquivo rdlc, eu inseri um parâmetro do tipo texto e inseri um controle Imagem como EXTERNAL

e setado com o parâmetro que criei.

No form, tenho esse código


Dim rptDataSource As ReportDataSource = Nothing

Me.ReportViewer1.RefreshReport()
With Me.ReportViewer1.LocalReport
        Dim rptStream As IO.Stream = GetReport(strReport & ".rdlc")
        .LoadReportDefinition(rptStream)
        .EnableExternalImages = True
        ' Define os parameters 
        Dim parameters(0) As ReportParameter
        parameters(0) = New ReportParameter("pImage", strImagem)
        .SetParameters(parameters)
        .DataSources.Clear()
End With
Me.ReportViewer1.RefreshReport()
rptDataSource = New ReportDataSource("FichaRegistro", RsDataSet.Tables(0))


Só que não está carregando a imagem, alguém pode me ajudar ?

Share this post


Link to post
Share on other sites
samesdavis

Problema resolvido



                       Dim rptStream As IO.Stream = GetReport(strReport & ".rdlc")
                       .EnableExternalImages = True
                       .LoadReportDefinition(rptStream)
                       If My.Computer.FileSystem.FileExists(strImagem) Then
                           strImagem = "file://" & strImagem
                       Else
                           strImagem = ""
                       End If
                       ' Define os parameters 
                       Dim parameters(0) As ReportParameter
                       parameters(0) = New ReportParameter("pImage", strImagem)
                       .SetParameters(parameters)
                       .DataSources.Clear()

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.