how to display photo dynamically in crystal report? RRS feed

  • Question

  • Please I need help, I am writing a student programme that display there photo dynamically whenever the I load the crystal report. But i do know how to do it. The photo path was stored in my database and am using visual studio 2005.
    Sunday, April 12, 2009 7:15 PM


All replies

  • Wednesday, April 15, 2009 5:14 AM
  • I have tried the code but it keep generating errors. But One thing I notice is that, He is field definition file for his database type. How can i create such a field
    Friday, April 17, 2009 6:24 PM
  • Saturday, April 18, 2009 11:16 AM
  • HI,
    Thank you for the link

    I would have reply earlier but I was very busy with the program.

    When I run the program  I downloaded from the link separately, it runs very well. I even adjusted the code it works.

    But when I inserted the code into my main program the crystal report does not display the image but rather a rectangular box.
    I use VS 2005. This is the code I used in loading the crystal report. The database had already been open.



    ' Create a dataTable


    Dim data As New DataTable


    ' Declare a row object.


    Dim row As DataRow

    data.TableName =



    ' Add a Byte Array field to the dataset.


    "image", System.Type.GetType("System.Byte[]"))


    ' Repeat for each image.if you have more than one...




    ' Read in the image file.(in VS2005 you can use ReadAllBytes and skip the streaming)


    Dim fs As New FileStream(AppDomain.CurrentDomain.BaseDirectory & "\StudentPhoto\" & sHeadGirl & ".jpg", FileMode.Open)


    ' Create a new binary reader object.


    Dim br As New BinaryReader(fs)


    ' Create a new row object.

    row = data.NewRow()


    ' Stream the image into the row.


    Dim imgbyte(fs.Length) As Byte


    ' read the bytes from the binary reader

    imgbyte = br.ReadBytes(Convert.ToInt32((fs.Length)))


    row(0) = imgbyte


    ' Add the row to the dataset.


    br =



    fs =



    Dim rptobj As New CrystalReport1 ' object of crystal report


    ' set the datasource of crystalreport object

    mdiSchool.myCrystalReportViewer.ReportSource = rptobj

    'set the report source



    Catch ex As Exception


    ' error handling


    "Missing 10157.jpg or nophoto.jpg in application folder")


    End Try

    mdiSchool.myCrystalReportViewer.ReportSource = (AppDomain.CurrentDomain.BaseDirectory &



    Dim myParameterFields As CrystalDecisions.Shared.ParameterFields = mdiSchool.myCrystalReportViewer.ParameterFieldInfo

    SetCurrentValuesForParameterField(myParameterFields, sHeadGirl)

    Please I really need help.

    Saturday, April 25, 2009 7:15 PM
  • Hi
    Sorry to say i dont knw visual basic. Can u put this issue as new thread under visual basic.It may help u
    Meghana Lohit
    Sunday, April 26, 2009 3:01 AM