RSS Forums RSS

Load image in report in runtime in ASP.Net

Reply
Posts: 3
Reputation: plugsharma is an unknown quantity at this point 
Solved Threads: 0
plugsharma plugsharma is offline Offline
Newbie Poster

Load image in report in runtime in ASP.Net

  #1  
Nov 11th, 2008
Hi,

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)

Dim data As New DataSet()
Dim row As DataRow

Step1 (Passing Image URL into dataset): my code is as follows
  1. Private Sub LoadImgUrl()
  2. Try
  3. data.Tables.Add("Image")
  4. data.Tables("Image").Columns.Add("Name")
  5.  
  6. row = data.Tables(0).NewRow()
  7. row(0) = Server.MapPath("DI.bmp")
  8. data.Tables(0).Rows.Add(row)
  9.  
  10. rptDoc.Load(Server.MapPath("rptImgUrl.rpt"))
  11. rptDoc.SetDataSource(data)
  12.  
  13. Response.Clear()
  14. Response.Buffer = True
  15. Response.ClearContent()
  16. Response.ClearHeaders()
  17.  
  18. Response.ContentType = "application/pdf"
  19. rptDoc.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, False, "")
  20.  
  21. Response.Flush()
  22.  
  23. Response.End()
  24. Catch ex As Exception
  25.  
  26. End Try
  27.  
  28. End Sub
--------------

Step2 (Storing Image into dataset): my code is as follows

  1. Private Sub LoadImgDS()
  2. Try
  3. data.Tables.Add("Image")
  4. data.Tables("Image").Columns.Add("Logo", System.Type.GetType("System.Byte[]"))
  5.  
  6. Dim fs As New System.IO.FileStream(Server.MapPath("DI.bmp"), System.IO.FileMode.Open, IO.FileAccess.Read)
  7. Dim br As New System.IO.BinaryReader(fs)
  8.  
  9. row = data.Tables("Image").NewRow()
  10. row("Logo") = br.ReadBytes(br.BaseStream.Length)
  11. data.Tables("Image").Rows.Add(row)
  12.  
  13. rptDoc.Load(Server.MapPath("rptImgDS.rpt"))
  14. rptDoc.SetDataSource(data)
  15.  
  16. Response.Clear()
  17. Response.Buffer = True
  18. Response.ClearContent()
  19. Response.ClearHeaders()
  20.  
  21. Response.ContentType = "application/pdf"
  22. rptDoc.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, False, "")
  23. br.Close()
  24. fs.Close()
  25.  
  26. br = Nothing
  27. fs = Nothing
  28. Catch ex As Exception
  29.  
  30. End Try
  31. End Sub
--------

In both case i am getting error "cannot obtain value" in following line:

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

Need help to solve this. Its very urgent.

Thanks
Last edited by peter_budo : Nov 12th, 2008 at 4:49 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Other Threads in the ASP.NET Forum
Views: 1182 | Replies: 0 | Currently Viewing: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 3:04 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC