<WebMethod()> _
Public Function Exc_Report(strName As String) As String
rpt.Load(Server.MapPath("CrystalReport1.rpt"))
rpt.SetParameterValue("test", "555")
Return True
End Function
Tag : .NET, Crystal Report, Web (ASP.NET), Web Service
Dim cryRpt AS New ReportDocument()
cryRpt.Load("Path\CrystalReport1.rpt")
Dim crtableLogoninfos As New TableLogOnInfos()
Dim crtableLogoninfo As New TableLogOnInfo()
Dim crConnectionInfo As New ConnectionInfo()
Dim CrTables As Tables
crConnectionInfo.ServerName = "YOUR SERVERNAME"
crConnectionInfo.DatabaseName = "DATABASE NAME"
crConnectionInfo.UserID = "USERID"
crConnectionInfo.Password = "PASSWORD"
CrTables = cryRpt.Database.Tables
For Each CrTable As CrystalDecisions.CrystalReports.Engine.Table In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = crConnectionInfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
Next
cryRpt.Refresh()
cryRpt.PrintToPrinter(2, True, 1, 2)
<WebMethod()> _
Public Function Exc_Report(strName As String) As String
rpt.Load(Server.MapPath("CrystalReport1.rpt"))
Dim crtableLogoninfos As New TableLogOnInfos()
Dim crtableLogoninfo As New TableLogOnInfo()
Dim crConnectionInfo As New ConnectionInfo()
Dim CrTables As Tables
' crConnectionInfo.ServerName = "RMWTEST" --> '' ServerName ไม่ใช้ได้มั้ยครับ ผมใช้ Oracle ครับ
crConnectionInfo.DatabaseName = "RMWTEST"
crConnectionInfo.UserID = "rmwsys"
crConnectionInfo.Password = "rmwsys"
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.Refresh()
rpt.PrintToPrinter(2, True, 1, 2) --->>vb:line 67 บรรทัดนี้ ครับ
End Function
-------- Error ------------
System.ComponentModel.Win32Exception: The specified printer has been deleted
at System.Drawing.Printing.StandardPrintController.OnStartPrint(PrintDocument document, PrintEventArgs e)
at System.Drawing.Printing.PrintController.Print(PrintDocument document)
at System.Drawing.Printing.PrintDocument.Print()
at CrystalDecisions.CrystalReports.Engine.FormatEngine.PrintToPrinter(Int32 nCopies, Boolean collated, Int32 startPageN, Int32 endPageN)
at CrystalDecisions.CrystalReports.Engine.ReportDocument.PrintToPrinter(Int32 nCopies, Boolean collated, Int32 startPageN, Int32 endPageN)
at WebService1.Service1.Exc_Report(String strName) in C:\onedrive\Server\WebService1\Service1.asmx.vb:line 67