Print without preview the crystal report

  • Thread starter Thread starter Shiraz Mansoor
  • Start date Start date
S

Shiraz Mansoor

Guest
Hi;

My system is a Standalone and with vb.net 2005 and Oracle database.

When Print through the crystal report viewer I am getting the correct output for given Batchno. bellow is my code:



Imports CrystalDecisions.CrystalReports.Engine

Imports CrystalDecisions.Shared

Imports System.Data.OleDb



Public Class frmTPReciepts

Public strBatchNo As String



Private Sub CrystalReportViewer1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Load


Dim crtableLogoninfos As New TableLogOnInfos

Dim crtableLogoninfo As New TableLogOnInfo

Dim crConnectionInfo As New ConnectionInfo

Dim CrTables As Tables

Dim CrTable As Table

Dim TableCounter



Dim crReportDocument As New TmpReceipt

With crConnectionInfo

.ServerName = "glhrm"

.DatabaseName = ""

.UserID = "PERMIT"

.Password = "ADM01"

End With

crReportDocument.Refresh()

CrTables = crReportDocument.Database.Tables


For Each CrTable In CrTables

crtableLogoninfo = CrTable.LogOnInfo

crtableLogoninfo.ConnectionInfo = crConnectionInfo

CrTable.ApplyLogOnInfo(crtableLogoninfo)

Next

CrystalReportViewer1.ReportSource = crReportDocument



Dim paramFields As New ParameterFields

Dim paramField As New ParameterField

Dim discreteVal As New ParameterDiscreteValue




paramField.ParameterFieldName = "BatchNo"

discreteVal.Value = strBatchNo

paramField.CurrentValues.Add(discreteVal)

paramFields.Add(paramField)



CrystalReportViewer1.ShowRefreshButton = False

CrystalReportViewer1.ShowTextSearchButton = False

CrystalReportViewer1.ShowExportButton = False

CrystalReportViewer1.Zoom(100)



For the above code It gives the correct result. but When I tried to print without preview that is Direct print it gives wrong output. that mean print comes with the different Batch no. Bellow is the code.



Dim prd As New System.Drawing.Printing.PrintDocument

Dim objRpt As New TmpReceipt



objRpt.PrintOptions.PrinterName = "Tally Dascom 2600 (Copy 1)"

objRpt.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperA4

objRpt.PrintToPrinter(1, False, 0, 0)


Please help me to Sort this out


Thanks

Continue reading...
 
Back
Top