ลองแล้วลองอีก ก็ยังไม่ได้เลยครับ (กรณีของผมไม่ได้ขึ้น Error แต่จากที่เคยแสดงได้ปกติ กลับเรียกแล้วเงียบไป)
จะไม่มี Error นี้ The maximum report processing jobs limit configured by your system administrator has been reached.
Public Class Conclusion
Inherits System.Web.UI.Page
Protected Overrides Sub OnInitComplete(e As EventArgs)
If Me.Session("ReportSource") IsNot Nothing Then
crvReportAllDep.ReportSource = Me.Session("ReportSource")
crvReportName.ReportSource = Me.Session("ReportSource")
End If
MyBase.OnInitComplete(e)
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Me.Session("ReportSource") = Nothing
'เคลียร์ session
crvReportAllDep.Visible = False
crvReportName.Visible = False
End If
End Sub
'Private rpt As New ReportDocument()
'Protected Overrides Sub OnUnload(e As EventArgs)
' MyBase.OnUnload(e)
' rpt.Close()
' rpt.Dispose()
' GC.Collect()
'End Sub
Protected Sub btnCallReport1_Click(sender As Object, e As EventArgs) Handles btnCallReport1.Click
If rdoByAll.Checked = False Then
Response.Write("<script language=javascript> alert('ต้องคลิกเลือกที่ ทั้งหมด(แบ่งตามแผนก) ก่อนครับ'); </script>")
Return
End If
Dim objConn As New SqlConnection
Dim objCmd As New SqlCommand
Dim dtAdapter As New SqlDataAdapter
Dim ds As New DataSet
Dim dt As DataTable
Dim strConnString As String
Dim strSQL As String = ""
strConnString = "Server= WEBSERVER\......, 1434 ;UID=basz;PASSWORD=xxxx;database=DBopd;Max Pool Size=400;Connect Timeout=600;"
If txtDateFrom1.Text <> "" Or txtDateTo1.Text <> "" Then
strSQL = "SELECT * FROM vwReport WHERE Date BETWEEN '" & Me.txtDateFrom1.Text & "' AND '" & Me.txtDateTo1.Text & "'"
Else
strSQL = "SELECT * FROM vwReport"
End If
objConn.ConnectionString = strConnString
With objCmd
.Connection = objConn
.CommandText = strSQL
.CommandType = CommandType.Text
End With
dtAdapter.SelectCommand = objCmd
dtAdapter.Fill(ds, "DataTableReport")
dt = ds.Tables(0)
dtAdapter = Nothing
objConn.Close()
objConn = Nothing
Dim rpt As New ReportDocument()
rpt.Load(Server.MapPath("rptShowAllDep.rpt"))
rpt.SetDataSource(dt)
Me.Session("ReportSource") = rpt 'Session Report
Me.crvReportAllDep.ReportSource = rpt
Me.crvReportAllDep.RefreshReport()
'rpt.Close()
'rpt.Dispose() ''ตรงนี้ก็ลองแล้ว ประกาศ rpt ข้างนอกก็ลองแล้ว ผมควรจะวางตรงไหนดี
'GC.Collect()
crvReportAllDep.Visible = True
crvReportName.Visible = False
End Sub