Load image in report in runtime in ASP.Net

I have to display a logo in crystal report in runtime. I have tried two solutions given in http://www.devx.com/codemag/Article/33658/1954 (Tip 6: Better Handling of Dynamic Images).

In both case i am getting error "cannot obtain value" in following line(detail in code snippet):

rptDoc.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, False, "")

Need help to solve this. Its very urgent.

Thanks
Dim data As New DataSet()
    Dim row As DataRow
 
Step1 (Passing Image URL into dataset): my code is as follows
Private Sub LoadImgUrl()
        Try
            data.Tables.Add("Image")
            data.Tables("Image").Columns.Add("Name")
 
            row = data.Tables(0).NewRow()
            row(0) = Server.MapPath("DI.bmp")
            data.Tables(0).Rows.Add(row)
 
            rptDoc.Load(Server.MapPath("rptImgUrl.rpt"))
            rptDoc.SetDataSource(data)
 
            Response.Clear()
            Response.Buffer = True
            Response.ClearContent()
            Response.ClearHeaders()
 
            Response.ContentType = "application/pdf"
            rptDoc.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, False, "")
            
            Response.Flush()
 
            Response.End()
        Catch ex As Exception
 
        End Try
 
    End Sub
--------------
 
Step2 (Storing Image into dataset): my code is as follows
 
Private Sub LoadImgDS()
        Try
            data.Tables.Add("Image")
            data.Tables("Image").Columns.Add("Logo", System.Type.GetType("System.Byte[]"))
 
            Dim fs As New System.IO.FileStream(Server.MapPath("DI.bmp"), System.IO.FileMode.Open, IO.FileAccess.Read)
            Dim br As New System.IO.BinaryReader(fs)
 
            row = data.Tables("Image").NewRow()
            row("Logo") = br.ReadBytes(br.BaseStream.Length)
            data.Tables("Image").Rows.Add(row)
 
            rptDoc.Load(Server.MapPath("rptImgDS.rpt"))
            rptDoc.SetDataSource(data)
 
            Response.Clear()
            Response.Buffer = True
            Response.ClearContent()
            Response.ClearHeaders()
 
            Response.ContentType = "application/pdf"
            rptDoc.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, False, "")
            br.Close()
            fs.Close()
 
            br = Nothing
            fs = Nothing
        Catch ex As Exception
 
        End Try
    End Sub
--------

Open in new window

kunasharmaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kunasharmaAuthor Commented:
Hi,

Thanks for your reply. I even tried this. But my requirement is different. I need to display without CRviewer.
I have to display the image through ExportToHttpResponse which embedding the report in browser.

Sharma
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.