我是水晶报告的新手。我已经有这个问题很长一段时间了,似乎无法解决它。我正在做的是运行报告并在响应中发回生成的 PDF。
问题是,当我从浏览器运行 asp.net 页面(运行报告)时,它第一次或第二次运行良好,但在那之后,浏览器一直在等待,我没有得到任何回复服务器,甚至没有错误!它只是保持加载很长时间。我什至重新安装了服务器,但仍然遇到同样的问题。在此页面的初始测试期间,我没有遇到此问题。
水晶报表是不可预测的,我不确定这是因为报表没有正确关闭还是连接不正确。
Windows Server 2003 - IIS 这是 vb.net 页面 -
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim connectionInfo As New ConnectionInfo
connectionInfo.ServerName = "UID=abc;PWD=abc;Driver= {SQL Server};Server=" & Page.Request.QueryString("server") & ";Database=" & Page.Request.QueryString("database")
Using report As New ReportDocument
report.Load(Server.MapPath("/report/Crystal/test.rpt"))
report.FileName = Server.MapPath("/report/Crystal/test.rpt")
SetDBLogonForReport(connectionInfo, report)
report.SetParameterValue("param1", Page.Request.QueryString("param1"))
Dim oStream As New MemoryStream()
oStream = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat)
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/pdf"
Response.BinaryWrite(oStream.ToArray())
report.Close()
End Using
Response.Flush()
Response.End()
End Sub
Private Sub SetDBLogonForReport(ByVal connectionInfo As ConnectionInfo, ByVal reportDocument As ReportDocument)
Dim tables As Tables
tables = reportDocument.Database.Tables
For Each table As CrystalDecisions.CrystalReports.Engine.Table In tables
Dim tableLogonInfo As New TableLogOnInfo
tableLogonInfo = table.LogOnInfo
tableLogonInfo.ConnectionInfo = connectionInfo
table.ApplyLogOnInfo(tableLogonInfo)
Next
End Sub
</div>
</form>