rp1.PrintOptions.PrinterName = "" ตรงนี้อยากให้เลือกเครื่องพิมพ์ก่อนครับ
rp1.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperA4
':::::::::::::เปิด Report โดยไม่ถามรหัสผ่าน:::::::::::::::::::::
Dim strDataReport As String = ""
Dim crtable As CrystalDecisions.CrystalReports.Engine.Table
Dim crTableLogonInto As CrystalDecisions.Shared.TableLogOnInfo
Dim cnConnInto As New CrystalDecisions.Shared.ConnectionInfo
With cnConnInto
cnConnInto.ServerName = "servertest"
cnConnInto.DatabaseName = Database_csw.Trim
cnConnInto.UserID = "sa"
cnConnInto.Password = "1234567890"
End With
For Each crtable In rp1.Database.Tables
crTableLogonInto = crtable.LogOnInfo
crTableLogonInto.ConnectionInfo = cnConnInto
crtable.ApplyLogOnInfo(crTableLogonInto)
Next
rp1.Database.Tables(0).SetDataSource(DTPay)
rp1.Subreports("Forest_LumberPaySub").Database.Tables(0).SetDataSource(DtPaySub)
rp1.Subreports("Forest_LumberPaySub").DataDefinition.FormulaFields("GenCode").Text = "'" & MD5(ToolSPrint.Text) & "'"
rp1.PrintToPrinter(1, False, 0, 0)