2015-09-11 2 views
0

Je télécharge des images sur le serveur et stocke leur chemin dans une table (varchar (MAX)).Image externe dans le rapport rdlc

J'ai réussi à créer un rapport et à afficher les enregistrements de cette table mais je n'ai pas pu lier l'image à sa source de données (chemin stocké).

Mon parcours ressemble à ceci:

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

J'utilise le code suivant pour remplir mon jeu de données

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 

S'il vous plaît Aide Merci!

Répondre

0

J'ai trouvé une solution que je veux partager avec vous et j'aimerais entendre vos commentaires,

J'ai modifié ma fonction Uploader pour enregistrer le chemin de l'image au format URI (encodée) (ie ..

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

pour afficher l'image sur je décode l'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 

pour afficher l'image dans votre rapport RDLC vient de mettre la source de contrôle d'image à externe et attribuer la valeur de l'image à la valeur du champ dans votre tableau Vos commentaires sont très appréciés, Merci!