Hello everybody,

I've got a problem with a report that hast to be exported to *.pdf
The first time it worked, but the second time it didn't. How strange is that!?

So when i click the button a new i.e. window shows up.

The first click works fine but when i want to open the report again the whole window is empty Somebody who know the answer??

Mycode:

VB Code:
  1. Dim Rep As crystalDecisions.CrystalReports.Engine.ReportDocument
  2.         Rep = New rptTest
  3.  
  4.         Dim tb As CrystalDecisions.CrystalReports.Engine.Table
  5.         Dim cn As New CrystalDecisions.Shared.ConnectionInfo
  6.  
  7.         cn.ServerName = *******
  8.         cn.DatabaseName = *******
  9.         cn.UserID = ******
  10.         cn.Password = ********
  11.  
  12.         Dim tblog As New CrystalDecisions.Shared.TableLogOnInfo
  13.         For Each tb In Rep.Database.Tables
  14.             tblog.ConnectionInfo = cn
  15.             tb.ApplyLogOnInfo(tblog)
  16.         Next
  17.  
  18.  
  19.         Dim strStream As New System.IO.BinaryReader(Rep.ExportToStream(CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat))
  20.  
  21.         Response.ClearContent()
  22.         Response.ClearHeaders()
  23.         Response.ContentType = "application/pdf"
  24.         Response.BinaryWrite(strStream.ReadBytes(strStream.BaseStream.Length))
  25.         Response.Flush()
  26.         Response.Close()
  27.         strStream.Close()

By the way, if i click again on the button for de 3rd time it works fine again. The 4th time not, the 5th time fine, 6 time not etc.