none
Print without preview the crystal report RRS feed

  • Question

  •  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

    Friday, August 9, 2019 5:39 AM

All replies

  • Hello,

    Best to ask your question here https://answers.sap.com/index.html


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Friday, August 9, 2019 11:11 AM