none
Mostrar imagen en Crystal Reports RRS feed

  • Pregunta

  • Buenas tardes

    Tengo que llenar los datos de una nueva credencial a partir de una informacion extraida de mi base de datos. En mi base de datos tengo un campo que se llama Photo en donde se almacena la imagen y esta la copio en un dataset externo. Al hacer un query antes de mostrar el reporte la el crystal me muestra el siguiente mensaje de error:

    System.IO.FileNotFoundException was unhandled
    Message: An unhandled exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
    Additional information: Could not load file or assembly 'file:///C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\dotnet1\crdb_adoplus.dll' or one of its dependencies. The system cannot find the file specified.

    Cabe destacar que dentro de la table tengo 2 campos uno que es el Id tipo integer y el otro es un campo tipo imagen. Y dentro de mi dataset externo El id es de tipo integer32 y el campo de Photo es tipo Byte()

    podrian ayudarme con este caso?

    Imports CrystalDecisions.CrystalReports.Engine
    Imports CrystalDecisions.Shared
    
    Imports System.Data.SqlClient
    Public Class frmRptVisitorId
        Public ContactId As Integer = Nothing
        Public PrntName As String = Nothing
        Public PrntCom As String = Nothing
        Public PrntVisId As String = Nothing
        Public PrntVisTo As String = Nothing
    
        Private Sub frmRptVisitorId_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Try
                Dim rptdoc As New ReportDocument
                Dim xsdPhoto As New Photo
                Dim DT As New DataTable
                Dim Parameter As ParameterFields = New ParameterFields()
    
                'write all if parameter is empty
                If PrntName = "" Then
                    PrntName = Nothing
                End If
                If PrntCom = "" Then
                    PrntCom = Nothing
                End If
                If PrntVisId = "" Then
                    PrntVisId = Nothing
                End If
                If PrntVisTo = "" Then
                    PrntVisTo = Nothing
                End If
    
                'pass Print Name parameter
                Dim NamePar As ParameterField = New ParameterField()
                Dim NameDiscrete As ParameterDiscreteValue = New ParameterDiscreteValue()
                NamePar.ParameterFieldName = "Contact"
                If PrntName = "" Then
                    NameDiscrete.Value = "-"
                Else
                    NameDiscrete.Value = PrntName
                End If
                NamePar.CurrentValues.Add(NameDiscrete)
                'charge parameters and sent to crystal
                Parameter.Add(NamePar)
                CRVVisitorId.ParameterFieldInfo = Parameter
    
                'pass Print Company parameter
                Dim ComPar As ParameterField = New ParameterField()
                Dim ComDiscrete As ParameterDiscreteValue = New ParameterDiscreteValue()
                ComPar.ParameterFieldName = "Company"
                If PrntCom = "" Then
                    ComDiscrete.Value = "-"
                Else
                    ComDiscrete.Value = PrntCom
                End If
                ComPar.CurrentValues.Add(ComDiscrete)
                'charge parameters and sent to crystal
                Parameter.Add(ComPar)
                CRVVisitorId.ParameterFieldInfo = Parameter
    
                'pass Print VisitorId parameter
                Dim VisIdPar As ParameterField = New ParameterField()
                Dim VisIdDiscrete As ParameterDiscreteValue = New ParameterDiscreteValue()
                VisIdPar.ParameterFieldName = "Id"
                If PrntVisId = "" Then
                    VisIdDiscrete.Value = "-"
                Else
                    VisIdDiscrete.Value = PrntVisId
                End If
                VisIdPar.CurrentValues.Add(VisIdDiscrete)
                'charge parameters and sent to crystal
                Parameter.Add(VisIdPar)
                CRVVisitorId.ParameterFieldInfo = Parameter
    
                'pass Visiting To parameter
                Dim VisToPar As ParameterField = New ParameterField()
                Dim VisToDiscrete As ParameterDiscreteValue = New ParameterDiscreteValue()
                VisToPar.ParameterFieldName = "Visit"
                If PrntVisTo = "" Then
                    VisToDiscrete.Value = "-"
                Else
                    VisToDiscrete.Value = PrntVisTo
                End If
                VisToPar.CurrentValues.Add(VisToDiscrete)
                'charge parameters and sent to crystal
                Parameter.Add(VisToPar)
                CRVVisitorId.ParameterFieldInfo = Parameter
    
                'Just set the name of data table
                Dt.TableName = "Photo"
                Dt = getPhoto()
                xsdPhoto.Tables("Photo").Merge(Dt)
    
                'Your .rpt file path will below
                rptdoc.Load(Application.StartupPath + "\VisitorId.rpt")
    
                'set dataset to the report viewer
                rptdoc.SetDataSource(xsdPhoto)
                CRVVisitorId.ReportSource = rptdoc
            Catch ex As Exception
                MsgBox("Error :" & ex.Source & " - " & ex.Message, MsgBoxStyle.Critical)
            End Try
        End Sub
        Private Function getPhoto() As DataTable
            Try
                SqlDs = New DataSet
                SqlConn.Open()
                SqlCmd = New SqlCommand("SELECT Id_Contact, Photo FROM tbl_contact WHERE Id_Contact=@ContactId;", SqlConn)
                SqlCmd.CommandType = CommandType.Text
                SqlCmd.Parameters.AddWithValue("@ContactId", ContactId)
                SqlAdap = New SqlDataAdapter(SqlCmd)
                SqlAdap.Fill(SqlDs, "Photo")
                SqlConn.Close()
            Catch ex As Exception
                MsgBox("Error :" & ex.Source & " - " & ex.Message, MsgBoxStyle.Critical)
            Finally
                SqlConn.Close()
            End Try
            Return SqlDs.Tables("Photo")
        End Function

    • Cambiado Enrique M. Montejo martes, 29 de mayo de 2018 18:31 Pregunta relacionada con Crystal Reports.
    lunes, 28 de mayo de 2018 19:32