cmd.CommandText = ("SELECT * FROM StockItem")cmd.Connection = Concon.Open()DSRpt.Clear()DA.SelectCommand = (cmd)DA.Fill(DSRpt, cmd.CommandText)DTRpt = DSRpt.Tables(0)
rptDoc = New ReportDocumentDim rptPath As String = Application.StartupPath & "\CrystalReceipt.rpt"rptDoc.Load(rptPath)rptDoc.SetDataSource(DTRpt)frmRptViewer.Text = "Print Sales Order"Con.Close()frmRptViewer.CrystalReportViewer1.ReportSource = rptDocDim doctoprint As New System.Drawing.Printing.PrintDocument()doctoprint.PrinterSettings.PrinterName = "EPSON LQ-300+ /II ESC/P 2" '"EPSON LQ-300+II ESC/P2" '(ex. "Epson SQ-1170 ESC/P 2")For i = 0 To doctoprint.PrinterSettings.PaperSizes.Count - 1 Dim rawKind As Integer If doctoprint.PrinterSettings.PaperSizes(i).PaperName = "A6 LR" Then rawKind = CInt(doctoprint.PrinterSettings.PaperSizes(i).GetType().GetField("kind", Reflection.BindingFlags.Instance Or Reflection.BindingFlags.NonPublic).GetValue(doctoprint.PrinterSettings.PaperSizes(i))) rptDoc.PrintOptions.PaperSize = rawKind Exit For End IfNextfrmRptViewer.ShowDialog()frmRptViewer.Dispose()rptDoc = Nothing
Thank you and your help will highly be appreciated