Dim ReportFile As String = ReportFolder & "rptSaleInvoice.rpt"
Dim rpt As New ReportDocument
Dim crtableLogoninfos As New TableLogOnInfos
Dim crtableLogoninfo As New TableLogOnInfo
Dim crConnectionInfo As New ConnectionInfo
Dim CrTables As Tables
Dim CrTable As Table
With crConnectionInfo
.ServerName = dbServer
.DatabaseName = dbName
.UserID = dbUserID
.Password = dbPwd
End With
rpt.Load(ReportFile)
CrTables = rpt.Database.Tables
For Each CrTable In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = crConnectionInfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
Next
With frmRunReport.CrvPreview
frmRunReport.Text = "พิม์บิลขายสินค้า Print Sale-Ducument"
rpt.Load(ReportFile)
rpt.SetParameterValue("SaleID", SaleID.Trim)
.ReportSource = rpt
.Refresh()
frmRunReport.ShowDialog()
End With
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Collections
Imports System.Data
Imports System.Diagnostics
Imports CrystalDecisions.CrystalReports.Engine
Imports System.Data.SqlClient
Imports System.Text
Imports CrystalDecisions.Shared
Namespace Helpdesk
Public Partial Class report_jobm
Inherits System.Web.UI.Page
Private oC As New oCenter()
Protected Sub Page_Load(sender As Object, e As EventArgs)
ConfigureCrystalReports()
End Sub
Private rpt As ReportDocument
Private Sub ConfigureCrystalReports()
rpt = New ReportDocument()
rpt.Load(Server.MapPath("report4.rpt"))
Dim crtableLogoninfo As New TableLogOnInfo()
Dim crConnectionInfo As New ConnectionInfo()
Dim CrTables As Tables
crConnectionInfo.ServerName = "TOEY-PC"
crConnectionInfo.DatabaseName = "Helpdesk"
crConnectionInfo.UserID = "sa"
crConnectionInfo.Password = "password"
CrTables = rpt.Database.Tables
For Each CrTable As CrystalDecisions.CrystalReports.Engine.Table In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = crConnectionInfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
Next
rpt.SetParameterValue("startdate", Session("startdate").ToString())
rpt.SetParameterValue("enddate", Session("enddate").ToString())
Me.CrystalReportViewer1.ReportSource = rpt
CrystalReportViewer1.PrintMode = CrystalDecisions.Web.PrintMode.ActiveX
Session("ReportSource1") = rpt
End Sub
Protected Overrides Sub OnUnload(e As EventArgs)
MyBase.OnUnload(e)
Try
If rpt IsNot Nothing Then
rpt.Close()
rpt.Dispose()
GC.Collect()
End If
' Exception
Catch ex As Exception
End Try
End Sub
Protected Sub rptCrystal_Unload(sender As Object, e As EventArgs)
Try
If rpt IsNot Nothing Then
rpt.Close()
rpt.Dispose()
GC.Collect()
End If
' Exception
Catch ex As Exception
End Try
End Sub
End Class
End Namespace