vb.net水晶报表关闭事件????
报表页面关闭时触发某个事件,释放报表资源。
释放对象为Dim rd As New CrystalDecisions.CrystalReports.Engine.ReportDocument()
rd.Close()
Dim rd As New CrystalDecisions.CrystalReports.Engine.ReportDocument()
Dim path1 As String = Server.MapPath("~/" + XiTongName + "/UTARpt/" + ReportName + ".rpt")
rd.Load(path1)
Dim ReportTime As String = Session("ReportTime")
Dim path2 As String = Server.MapPath("~/ReportMdb/" + ReportName + Account + ReportTime + ".mdb")
Dim connectionstring As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path2
Dim conn As New OleDbConnection(connectionstring)
Dim sqlcx() As String = Session("sql")
Dim TableName() As String = Session("Table")
Dim rpttablename() As String = Session("rpttablename")
Dim ds As New DataSet()
Dim n As Integer
For n = 0 To sqlcx.Length - 1
If sqlcx(n) = "" Then
Continue For
End If
Dim da As New OleDbDataAdapter("select * from " + TableName(n), conn)
da.Fill(ds, rpttablename(n))
Next
Dim da1 As New OleDbDataAdapter("SELECT * FROM ReportCustomerInfo", conn)
da1.Fill(ds, "ReportCustomerInfo")
rd.SetDataSource(ds)
rd.Database.Tables(0).SetDataSource(ds.Tables(0))
conn.Close()
conn.Dispose()
CrystalReportViewer1.ReportSource = rd
End If (最后要释放的即为CrystalReportViewer1.ReportSource = rd这个rd)