Error in Printing Crystal Report Directly to Printer using SDK Code

Hello ,
I am trying to print a crystal report created in SAP Crystal Reports 2008 through SDk Code using one parameter
as (Document Number).But While running the Code the Report is not getting printed and also the system is
not able to fetch the correct data in the report using the supplied parameter .
I am using Visual Studio 2005 Crystal Report dll s in my code :-
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CrystalDecisions.CrystalReports
Imports System
Imports System.Data.SqlClient
Imports System.IO
For Clarification i am pasting my code below :-
            Dim oRpt As ReportDocument
            oRpt = New ReportDocument
            oRpt.Load(Path)
            With crConnectionInfo
                .ServerName = Server
                .DatabaseName = Database
                .UserID = User
                .Password = Password
            End With
            CrTables = oRpt.Database.Tables
            For Each CrTable In CrTables
                crtableLogoninfo = CrTable.LogOnInfo
                crtableLogoninfo.ConnectionInfo = crConnectionInfo
                CrTable.ApplyLogOnInfo(crtableLogoninfo)
            Next
            oRpt.ParameterFields("Document Number").CurrentValues.AddValue(Parameter)
            If Printer <> "" Then
                oRpt.PrintOptions.PrinterName = Printer
            End If
            oRpt.PrintToPrinter(Copies, False, 0, 1)
        Catch ex As Exception
            SBO_Application.MessageBox(ex.Message)
        End Try
Please suggest me what i have to do in my code to print the report with correct data in report.
Thanks & Regards,
Amit

k

Similar Messages

  • Error - Printing a report directly to printer

    Hi,
    i'm using oracle forms 9i and i'm trying to print a report directly to printer. I using the code above:
    SET_REPORT_OBJECT_PROPERTY(ReportId,REPORT_DESFORMAT,'PDF');
    SET_REPORT_OBJECT_PROPERTY(ReportId,REPORT_SERVER,GetReportTnsName);
    IF ReportDesType = 'CACHE' THEN
    SET_REPORT_OBJECT_PROPERTY(ReportId,REPORT_DESTYPE,CACHE);
    ReportServerJob:=RUN_REPORT_OBJECT(ReportId, PList);
    rep_status := report_object_status(ReportServerJob);
    IF rep_status=’FINISHED’ THEN
    JobId := substr(ReportServerJob,length(GetReportTnsName)+2,length(ReportServerJob));
    WEB.SHOW_DOCUMENT ('/reports/rwservlet/getjobid'||JobId||'?server='||GetReportTnsName,'_blank');
    ELSE
    message ('Error’);
    END IF;
    -- logic for sending report directly to printer
    ELSIF ReportDesType = 'PRINTER' then
    SET_REPORT_OBJECT_PROPERTY(ReportId,REPORT_DESTYPE,PRINTER);
    SET_REPORT_OBJECT_PROPERTY(ReportId,REPORT_DESNAME,:parameter.p_print);
    ReportServerJob:=RUN_REPORT_OBJECT(ReportId, PList);
    rep_status := report_object_status(ReportServerJob);
    IF rep_status=’FINISHED’ THEN
    message ('Report sent to printer successfully');
    ELSE
    --handle errors
    message ('Error’);
    END IF;
    end if ;
    i get this error :
    REP-50157: Erro no envio do ficheiro para a impressora lp65. Sair com o código de erro 64
    NEED HELP !!
    Regards,

    The printer has to be known on the server where the Reports service runs.
    Also, the user who runs the Reports service has to have access to that printer. If you are running on Windows, Reports Service runs as Local system by default. Change that to a real (domain) user, who has access to the printer.

  • Print Crystal Report directly from C# without using Report Viewer

    Hello All,
    I need to print a crystal report directly to the printer without using ReportViewer in C#. I've a CrystalReport2(belowCode) which requires a query (Select * from JobHeader where JobNumber='J012345') to display all the data. I'm stuck with database connection
    and putting all the data to DataAdapter in C# (Below Code). I also have 8 subreports in my CrystalReport2. Can somebody please give me hand on this? I'm struggling with it. Thanks.
    Regards
    using CrystalDecisions.CrystalReports.Engine;
    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;
    using System.Data.SqlClient;
    namespace csharp_win_printtoprinter
    /// <summary>
    /// Summary description for Form1
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    //CR Variables
    ReportDocument crReportDocument;
    private System.Windows.Forms.Button button1;
    private System.Windows.Forms.PrintDialog printDialog1;
    private System.Windows.Forms.Button button2;
    private System.Drawing.Printing.PrintDocument printDocument1;
    private CrystalDecisions.Windows.Forms.CrystalReportViewer crystalReportViewer1;
    private CrystalReport1 CrystalReport11;
    private Chart Chart1;
    /// <summary>
    /// Required designer variable
    /// </summary>
    private System.ComponentModel.Container components = null;
    public Form1()
    // Required for Windows Form Designer support
    InitializeComponent();
    // TODO: Add any constructor code after InitializeComponent call
    /// <summary>
    /// Clean up any resources being used
    /// </summary>
    protected override void Dispose( bool disposing )
    if( disposing )
    if (components != null)
    components.Dispose();
    base.Dispose( disposing );
    #region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor
    /// </summary>
    private void InitializeComponent()
    this.button1 = new System.Windows.Forms.Button();
    this.printDialog1 = new System.Windows.Forms.PrintDialog();
    this.button2 = new System.Windows.Forms.Button();
    this.printDocument1 = new System.Drawing.Printing.PrintDocument();
    this.crystalReportViewer1 = new CrystalDecisions.Windows.Forms.CrystalReportViewer();
    this.Chart1 = new csharp_win_printtoprinter.Chart();
    this.CrystalReport11 = new csharp_win_printtoprinter.CrystalReport1();
    this.SuspendLayout();
    // button1
    this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
    this.button1.Location = new System.Drawing.Point(32, 56);
    this.button1.Name = "button1";
    this.button1.Size = new System.Drawing.Size(160, 104);
    this.button1.TabIndex = 0;
    this.button1.Text = "Print Report No Choose Printer";
    this.button1.Click += new System.EventHandler(this.button1_Click);
    // button2
    this.button2.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
    this.button2.Location = new System.Drawing.Point(272, 56);
    this.button2.Name = "button2";
    this.button2.Size = new System.Drawing.Size(160, 104);
    this.button2.TabIndex = 1;
    this.button2.Text = "Choose Printer";
    this.button2.Click += new System.EventHandler(this.button2_Click);
    // crystalReportViewer1
    this.crystalReportViewer1.ActiveViewIndex = 0;
    this.crystalReportViewer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
    this.crystalReportViewer1.Cursor = System.Windows.Forms.Cursors.Default;
    this.crystalReportViewer1.Location = new System.Drawing.Point(47, 188);
    this.crystalReportViewer1.Name = "crystalReportViewer1";
    this.crystalReportViewer1.ReportSource = this.CrystalReport11;
    this.crystalReportViewer1.Size = new System.Drawing.Size(903, 296);
    this.crystalReportViewer1.TabIndex = 2;
    // Form1
    this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
    this.ClientSize = new System.Drawing.Size(1164, 505);
    this.Controls.Add(this.crystalReportViewer1);
    this.Controls.Add(this.button2);
    this.Controls.Add(this.button1);
    this.Name = "Form1";
    this.Text = "Form1";
    this.Load += new System.EventHandler(this.Form1_Load);
    this.ResumeLayout(false);
    #endregion
    /// <summary>
    /// The main entry point for the application
    /// </summary>
    [STAThread]
    static void Main()
    Application.Run(new Form1());
    private void button1_Click(object sender, System.EventArgs e)
    crReportDocument = new ReportDocument();
    //Create an instance of a report
    crReportDocument = new CrystalReport2();
    //Use error handling in case an error occurs
    try
    //Set the printer name to print the report to. By default the sample
    //report does not have a defult printer specified. This will tell the
    //engine to use the specified printer to print the report. Print out
    //a test page (from Printer properties) to get the correct value.
    System.Drawing.Printing.PrintDocument printDocument = new System.Drawing.Printing.PrintDocument();
    crReportDocument.PrintOptions.PrinterName = printDocument.PrinterSettings.PrinterName;
    //Start the printing process. Provide details of the print job
    //using the arguments.
    crReportDocument.PrintToPrinter(0 ,true , 1, 1);
    //Let the user know that the print job is completed
    MessageBox.Show("Report finished printing!");
    catch(Exception err)
    MessageBox.Show(err.ToString(), "Unexpected exception");
    private void Form1_Load(object sender, System.EventArgs e)
    private void button2_Click(object sender, System.EventArgs e)
    //Open the PrintDialog
    this.printDialog1.Document = this.printDocument1;
    DialogResult dr = this.printDialog1.ShowDialog();
    if(dr == DialogResult.OK)
    //Get the Copy times
    int nCopy = this.printDocument1.PrinterSettings.Copies;
    //Get the number of Start Page
    int sPage = this.printDocument1.PrinterSettings.FromPage;
    //Get the number of End Page
    int ePage = this.printDocument1.PrinterSettings.ToPage;
    string PrinterName = this.printDocument1.PrinterSettings.PrinterName;
    crReportDocument = new ReportDocument();
    //Create an instance of a report
    crReportDocument = new Chart();
    try
    //Set the printer name to print the report to. By default the sample
    //report does not have a defult printer specified. This will tell the
    //engine to use the specified printer to print the report. Print out
    //a test page (from Printer properties) to get the correct value.
    crReportDocument.PrintOptions.PrinterName = PrinterName;
    //Start the printing process. Provide details of the print job
    //using the arguments.
    crReportDocument.PrintToPrinter(nCopy, false, sPage, ePage);
    //Let the user know that the print job is completed
    MessageBox.Show("Report finished printing!");
    catch(Exception err)
    MessageBox.Show(err.ToString());

    1. This is a VB.Net forum not a Visual C# forum. For Visual C# questions try this forum.
    Visual C#
    2. Crystal Reports are not supported by Microsoft. Therefore, unless somebody responding in the Visual C# forum has experience with whichever version of Crystal Reports you are using, you will probably not receive an answer in the Visual C# forum. SAP has
    their own assistance for Crystal Reports using Visual Studio. You can try to find an appropriate forum to ask questions in at SAP in the below link.
    SAP Community Network
    La vida loca

  • Print RDLC Report Directly to Printer with SubReports!

    I am currently printing a report directly to the default printer using the code from this link. 
    http://msdn.AddHandler
    ReportViewer1.LocalReport.SubreportProcessing, AddressOf SubreportProcessingEventHandler
    and this code:
    Public Sub SubreportProcessingEventHandler(ByVal sender As Object, ByVal e As SubreportProcessingEventArgs)
    Dim zrpt = e.ReportPath
    Select Case zrpt
    Case "WOPartsSubReport"
    Dim ds1 As New WOPartsSubReportDataSet
    Dim da1 As New WOPartsSubReportDataSetTableAdapters.wopartsTableAdapter
    da1.Fill(ds1.woparts)
    e.DataSources.Add(New ReportDataSource("DataSet1", ds1.Tables("woparts")))
    Case "WOLaborSubReport"
    Dim ds2 As New WOLaborSubReportDataSet
    Dim da2 As New WOLaborSubReportDataSetTableAdapters.wolaborTableAdapter
    da2.Fill(ds2.wolabor)
    e.DataSources.Add(New ReportDataSource("DataSet1", ds2.Tables("wolabor")))
    Case "WOLockoutSubReport"
    Dim ds As New WOLockOutSubReportDataSet
    Dim da As New WOLockOutSubReportDataSetTableAdapters.wolockTableAdapter
    da.Fill(ds.wolock)
    e.DataSources.Add(New ReportDataSource("DataSet1", ds.Tables("wolock")))
    End Select
    End Sub
    But now that I am NOT using a reportviewer how can I still get the subreports to work and still print directly to the printer?  Where would I put the code to do that?
    Thanks,
    Stacy

    Hi Stacy,
    Sorry for the delay.
    It’s Christian that I have involved to help on this issue. Maybe the issue requires a more in-depth level of support. Alternatively, you could contact Microsoft Customer Support Services (CSS) via telephone so that a dedicated Support Professional can assist
    you in a more efficient manner. Please understand that contacting phone support will be a charged call, but it will be free if this is a product issue. To obtain the phone numbers for specific technology request please take a look at the web site listed below:
    http://support.microsoft.com/default.aspx?scid=fh;EN-US;PHONENUMBERS
    Another option would be creating a thread on our Connect site:
    http://connect.microsoft.com/sql.
    Regards,
    Mike Yin
    If you have any feedback on our support, please click
    here
    Mike Yin
    TechNet Community Support

  • Printing PDF report directly to printer, not using orarrp utility

    The orarrp utility works only with Windows machines and it
    requires installation on both the client machines and servers to
    support. We need a more general solution.
    Adobe has a java application/applet/javabean (and support
    classes) to view PDF, and it is easy to write a java driver
    which can be used in place of the orarrp utility. However,
    Adobe's Java Viewer is extremely slow, does not produce quality
    output, and is explicitly not supported by Adobe.
    My question then relates to Reports. When the Report server
    returns a PDF in the Previewer, I'm expecting the JINITIATOR,
    used by Forms, is also used to support the Report frame and
    functionality, including eventual printing. If this is the case,
    is there not a set of classes, downloaded with Jinitiator, which
    support the fonts, and printing of PDF to locally attached
    printers?
    And if so, shouldn't we, in Java, be able to make use of these
    classes and their APIs to print PDF files directly to locally
    attached printers without the need for Previewing first?

    within a forms trigger:
    1. generate the report
    2. copy from iAS to local
    like: webutil_file_transfer.url_to_client()
    3. print.exe /d:printer filename (for windows OS)

  • How to print a report directly on printer

    Hi,
    anyone, plz help me in finding out, why my report i.e. i m sending directly to printer is getting printed like html codes?
    Plz help asap.
    Br,
    Divya Alok

    please check out the following link.
    Print report directly
    just mention the printer name i hope it helps u.
    sarah
    Edited by: QGIRCO on Apr 1, 2010 3:01 AM

  • Error while importing crystal report request K900529.R21 using STMS

    Hello,
    While importing in sap BI system through STMS, request K900529.R21 getting the following error :
    Transport control program tp ended with error code 0212
    Errors: could not access file as supposed (see dev_tp or S
    DETAIL ERROR DESC
    This is tp version 372.03.35 (release 700, unicode enabled)
    INTEL\sapmnt\trans\cofiles\K900529.R21 for transport: R21K900529: Per
    HALT 20080124213745
    ERROR:
    INTEL\sapmnt\trans\cofiles\K900529.R21 : cant open
    : Permission denied
    ERROR: EXIT(16) -> process ID is: 7048
    tp returncode summary:
    TOOLS: Highest return code of single steps was: 16
    ERRORS: Highest tp internal error was: 0212
    standard output from tp and from tools called by tp:
    Thanks,
    Ravi

    Hi Ravindra,
             Welcome to SDN......
    Check  for authorizations.
    Thanks,
    Vijay.

  • Error message when trying to view/print Crystal reports in B1

    I get the following Error message when trying to view/print crystal reports in SAP B1/Crystal Reports Integration Tool for SAP Business One:   
    " Could not load file or assembly 'Crystal Decisions Windows Forms, version=12.0.2000.0, Culture=neutral, Public Key Token=692fbea551e1304'  or one of its dependencies.  The system cannot find the file specified.  ????

    Hi
    Common issues for this :
    1. Once you install crystall add on ,you need to go to Crystal report Administration >Account setup .
    Put on the user name and password and click on creating ext tables
    Try then running the report .
    If not the case ,
    make sure you install runtime .
    You need :
    1.Crystal report basic from SAP download -(Not necessary if you want only report viewer >
    2.You need to have crystal integration addon (I think service pack is SP1)
    3.Make sure you have runtime install
    When you are installing ,make sure you restart your PC before you do or remove temporary file s
    Hope this solves your issue
    Bishal

  • Crystal Reports 2008 viewer, print function, Comunication error

    I installed cr2008 on a web server and isntalled sp0
    if I bring up a reprot in smartviewer from a client it works and I can print
    once I installed sp1, sp2 and or sp3 for crystal reports 2008 the print button in crystal reports viewer gives an error when I click the print button.
    If I remove and re-isntall cr2008 and just installed sp0 the print button works again
    Is there a fix to make the print button work in crystal reports smart viewer once sp1 or above have been installed
    thank you
    ted

    Translating the error message on bablefish I get:
    Mistake with the store of the data bank information. Mistake in the file Report {C6512421-348A-4621-B1ED-895D28646A0A} .rpt
    Which I'm sure is not 100% accurate, but it gives a good hint. As well, because of this:
    "Do I need to install an additional / diffrent runtime than 2008 Runtime"
    I wonder how you installed the CR 12 runtime on that computer? For more info on CR runtimes, see [this|https://wiki.sdn.sap.com/wiki/display/BOBJ/CrystalReportsforVisualStudio.NETRuntimeDistribution-Versions9.1to12.0] wiki.
    If my suggestion above does not help, make sure the Win\temp directory can be accessed buy the application. Crystal Reports runtime needs to write and read files from the temp directory.
    Ludek

  • Printing Crystal Report to Printer from Windows Service

    Hello Support,
    We are currently using 13.0.3.612 version of Crystal report. We want to print the report to the printer from the windows service. For printing the report to the printer we are using the “PrintOutputController.PrintReport” method. At our end on the Windows 8 machine this method is giving following error:
    Message: Error HRESULT E_FAIL has been returned from a call to a COM component.
    StackTrace:    at CrystalDecisions.ReportAppServer.Controllers.PrintOutputControllerClass.PrintReport(PrintReportOptions options)
       at PMLWLibrary.CrystalReport.LoadReports()
    And on the Windows 7 machine the report is sent to the print spooler, however the report is not printed on the printer. Not sure what could be causing the issue. Can you please let us know what could be causing the issue.

    Hi Brian,
    Thank you for your response.
    We tried running the service under the domain user account as well which has access to the printer, but even this fails. Further, from the regular .net application when we try to print the report to the printer, it directly prints the report without displaying any print window. So I assume that even from the service no print window should be launched. Can you please confirm on this.
    We are attaching herewith the code snippet which we have used to print to printer through the service. Can you please review the same and let us know if we are missing something here.
    Dim printReportOptions As New CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions
    Dim printOutputController As New CrystalDecisions.ReportAppServer.Controllers.PrintOutputController
    Dim rptClientDoc As CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument
    rptClientDoc = ReportDocument.ReportClientDocument
    printReportOptions.PrinterName = "\\pc2\HP LaserJet 1015"
    printReportOptions.JobTitle = [Enum].GetName(GetType(ReportNames), PrinterSetting)
    printReportOptions.Collated = False
    printReportOptions.AddPrinterPageRange(1, 1)
    rptClientDoc.PrintOutputController.PrintReport(printReportOptions)

  • Print report directly to printer

    I am using Crystal Reports XI R2 to generate reports in Powerbuilder. I want to know whether it is possible to print the report directly to a printer without displaying it in the Crystal Report viewer?
    Thanks,
    Amol

    I have a very similar problem, not being able to print a report directly to the printer.
    But I am calling Crystal Reports v8.5 from VB6.  I have tried the  suggested code:
    report.PrintOut(prompt user, numberofCopy, collated, startpage, endpage)
    but get a "type mismatch" compiler error  with "PrintOut" highlighted when compiling, eventhough the inline help shows this method and matching arguments.
    I wonder if I have the correct DLL referenced.
    This report runs fine thru the preview window, but since this is a series of reports about 100 pages, don't really want the user to have to specify print dozens of times.
    Thanks,
    Gene

  • How to print the report directly without previewing (report viewer) using c# windows application

    Hi,
    Currently, we are using crystal report to all of our reporting applications, but since I/users have encountered some issues about CR's speed to load only a simple report, maybe it is now time for us to adopt a new reporting environment in which I think SSRS
    can fill this problem.
    To start with, I have here a sample code, that uses the crystal report to print the report directly without previewing:
    csCashInvoiceCal csCashCal; --Crystal report name .rpt
    dsCsReceipt dsCs; --created dataset
    DataTable u;
    DataRow s;
    private System.Drawing.Printing.PrintDocument printDocument1;
    private System.Windows.Forms.PrintDialog printDialog1;
    ParameterValues paramValue;
    ParameterDiscreteValue discreteValue;
    ParameterFieldDefinition fieldDefinition;
    private void btnPrint_Click(object sender, EventArgs e)
    this.Cursor = Cursors.WaitCursor;
    loadReceipt2();
    print2();
    csCashCal.Close();
    this.Cursor = Cursors.Default;
    private void loadReceipt2()
    dsCs = new dsCsReceipt(); --created dataset
    u = dsCs.Tables.Add("DtCsReceipt");
    u.Columns.Add("Qty", Type.GetType("System.String"));
    u.Columns.Add("UOM", Type.GetType("System.String"));
    u.Columns.Add("Description", Type.GetType("System.String"));
    u.Columns.Add("UnitPrice", Type.GetType("System.String"));
    u.Columns.Add("Discount", Type.GetType("System.String"));
    u.Columns.Add("Amount", Type.GetType("System.String"));
    try
    for (int i = 0; i < dgvDesc.Rows.Count - 1; i++)
    s = u.NewRow(); double.TryParse(dgvDesc.Rows[i].Cells[Discount2.Name].Value.ToString(), out discount);
    s["Qty"] = double.Parse(dgvDesc.Rows[i].Cells[Qty.Name].Value.ToString());
    s["UOM"] = dgvDesc.Rows[i].Cells[Uom2.Name].Value.ToString();
    s["Description"] = invcode + dgvDesc.Rows[i].Cells[Description.Name].Value.ToString();
    s["UnitPrice"] = dgvDesc.Rows[i].Cells[UnitPrice.Name].Value.ToString();
    if (discount != 0)
    s["Discount"] = "(" + string.Format("{0:0.##}", discount) + "%)";
    else
    s["Discount"] = "";
    s["Amount"] = dgvDesc.Rows[i].Cells[Amount2.Name].Value.ToString();
    u.Rows.Add(s);
    catch (Exception) { }
    csCashCal = new csCashInvoiceCal();
    csCashCal.SetDataSource(dsCs.Tables[1]);
    //csCashCal.Refresh();
    loadParameter2();
    private void loadParameter2()
    ParameterFieldDefinitions paramFieldDefinitions;
    paramValue = new ParameterValues();
    discreteValue = new ParameterDiscreteValue();
    paramFieldDefinitions = csCashCal.DataDefinition.ParameterFields;
    discreteValue.Value = date;
    fieldDefinition = paramFieldDefinitions["Date"];
    commonParam();
    discreteValue.Value = txtcsno.Text;
    fieldDefinition = paramFieldDefinitions["InvoiceNo"];
    commonParam();
    discreteValue.Value = txtNameTo.Text;
    fieldDefinition = paramFieldDefinitions["CustomerName"];
    commonParam();
    discreteValue.Value = txtAdd.Text;
    fieldDefinition = paramFieldDefinitions["CustomerAddress"];
    commonParam();
    ------other parameters----
    private void commonParam()
    paramValue.Clear();
    paramValue.Add(discreteValue);
    fieldDefinition.ApplyCurrentValues(paramValue);
    private void print2()
    using (printDocument1 = new System.Drawing.Printing.PrintDocument())
    using (this.printDialog1 = new PrintDialog())
    //this.printDialog1.UseEXDialog = true;
    this.printDialog1.Document = this.printDocument1;
    DialogResult dr = this.printDialog1.ShowDialog();
    if (dr == DialogResult.OK)
    int nCopy = this.printDocument1.PrinterSettings.Copies;
    int sPage = this.printDocument1.PrinterSettings.FromPage;
    int ePage = this.printDocument1.PrinterSettings.ToPage;
    string PrinterName = this.printDocument1.PrinterSettings.PrinterName;
    try
    csCashCal.PrintOptions.PrinterName = PrinterName;
    csCashCal.PrintToPrinter(nCopy, false, sPage, ePage);
    printcount++;
    //saveCountPrint();
    catch (Exception err)
    MessageBox.Show(err.ToString());
    This is only a simple sales receipt application that uses dgv and textboxes to push its data to dataset to the crystal report, a simple one but there are instances that it is very slow.
    But I'm having trouble implementing this using SSRS, since I'm only new to this one, wherein I created the report using report wizard, with two button options inside the form for print preview or direct print selection. Actually, it is very easy to implement
    with print preview because it uses reportviewer. My problem is that how can I print the report directly without using a reportviewer?
    So here is my code so far which I don't know what's next:
    private void button2_Click(object sender, EventArgs e)
    this.Cursor = Cursors.WaitCursor;
    loadReceipt3();
    //print3();
    this.Cursor = Cursors.Default;
    ReportParameter[] parameter = new ReportParameter[11];
    private void loadParameter3()
    parameter[0] = new ReportParameter("InvoiceNo", txtcsno.Text);
    parameter[1] = new ReportParameter("Date", date);
    parameter[2] = new ReportParameter("CustomerTin", txtTin.Text);
    parameter[3] = new ReportParameter("CustomerName", txtNameTo.Text);
    parameter[4] = new ReportParameter("CustomerAddress", txtAdd.Text);
    parameter[5] = new ReportParameter("Agent", agent);
    parameter[6] = new ReportParameter("Discount", "Discount: ");
    parameter[7] = new ReportParameter("TotalDiscount", lblDiscount.Text + "%");
    parameter[8] = new ReportParameter("TotalSales", rdtotal);
    parameter[9] = new ReportParameter("Tax", rdtax);
    parameter[10] = new ReportParameter("TotalAmount", rdnet);
    private void loadReceipt3()
    DataSet dsrs = new DataSet();
    DataTable dtrs = new DataTable();
    DataRow drs;
    dtrs.Columns.Add("Qty", Type.GetType("System.String"));
    dtrs.Columns.Add("UOM", Type.GetType("System.String"));
    dtrs.Columns.Add("Description", Type.GetType("System.String"));
    dtrs.Columns.Add("UnitPrice", Type.GetType("System.String"));
    dtrs.Columns.Add("Discount", Type.GetType("System.String"));
    dtrs.Columns.Add("Amount", Type.GetType("System.String"));
    try
    for (int i = 0; i < dgvDesc.Rows.Count - 1; i++)
    drs = dtrs.NewRow();
    drs["Qty"] = double.Parse(dgvDesc.Rows[i].Cells[Qty.Name].Value.ToString());
    drs["UOM"] = dgvDesc.Rows[i].Cells[Uom2.Name].Value.ToString();
    drs["Description"] = invcode + dgvDesc.Rows[i].Cells[Description.Name].Value.ToString();
    drs["UnitPrice"] = dgvDesc.Rows[i].Cells[UnitPrice.Name].Value.ToString();
    if (discount != 0)
    drs["Discount"] = "(" + string.Format("{0:0.##}", discount) + "%)";
    else
    drs["Discount"] = "";
    drs["Amount"] = dgvDesc.Rows[i].Cells[Amount2.Name].Value.ToString();
    dtrs.Rows.Add(s);
    catch (Exception) { }
    int addtlRow = 7;
    if (addtlRow > (count - 1))
    addtlRow = addtlRow - (count - 1);
    for (int i = 0; i < addtlRow; i++)
    dtrs.Rows.Add();
    loadParameter3();
    LocalReport localreport = new LocalReport();
    localreport.SetParameters(parameter);
    localreport.DataSources.Clear();
    localreport.DataSources.Add(new ReportDataSource("dsSalesReceiptSsrs", dtrs));
    localreport.Refresh();
    //what's next....
    So what's next after local..refresh()? Actually, I have googled a lot but I didn't found the exact solution that I'm looking for which confuses me a lot.
    Anyway I'm using VS 2010 with sql server 2012 express.
    You're help will be greatly appreciated.
    Thank you,
    Hardz

    After some further studies with ReportViewer controls and with the use of this tutorial @ : http://msdn.microsoft.com/en-us/library/ms252091.aspx, which helps me a lot on how to print a report without using a report viewer, I found out what is missing
    with my code above and helps solve my question.
    Here's the continuation of the code above:
    private void loadReceipt3()
    loadParameter3();
    LocalReport localreport = new LocalReport();
    localreport.ReportPath = @"..\..\SsrsCashReceipt.rdlc";
    localreport.SetParameters(parameter);
    localreport.DataSources.Clear();
    localreport.DataSources.Add(new ReportDataSource("dsSalesReceiptSsrs", dtrs));
    Export(localreport);
    print4();
    private IList<Stream> m_streams;
    private int m_currentPageIndex;
    private void Export(LocalReport report)
    string deviceInfo =
    @"<DeviceInfo>
    <OutputFormat>EMF</OutputFormat>
    <PageWidth>8.5in</PageWidth>
    <PageHeight>11in</PageHeight>
    <MarginTop>0.25in</MarginTop>
    <MarginLeft>0.25in</MarginLeft>
    <MarginRight>0.25in</MarginRight>
    <MarginBottom>0.25in</MarginBottom>
    </DeviceInfo>";
    Warning[] warnings;
    m_streams = new List<Stream>();
    report.Render("Image", deviceInfo, CreateStream,
    out warnings);
    foreach (Stream stream in m_streams)
    stream.Position = 0;
    private void print4()
    if (m_streams == null || m_streams.Count == 0)
    throw new Exception("Error: no stream to print.");
    PrintDocument printDoc = new PrintDocument();
    PrintDialog printDlg = new PrintDialog();
    printDlg.Document = printDoc;
    DialogResult dr = printDlg.ShowDialog();
    if (dr == DialogResult.OK)
    if (!printDoc.PrinterSettings.IsValid)
    throw new Exception("Error: cannot find the default printer.");
    else
    printDoc.PrintPage += new PrintPageEventHandler(PrintPage);
    m_currentPageIndex = 0;
    printDoc.Print();
    Dispose();
    public void Dispose()
    if (m_streams != null)
    foreach (Stream stream in m_streams)
    stream.Close();
    m_streams = null;
    private Stream CreateStream(string name, string fileNameExtension, Encoding encoding, string mimeType, bool willSeek)
    Stream stream = new FileStream(name + "." + fileNameExtension,
    FileMode.Create);
    m_streams.Add(stream);
    return stream;
    private void PrintPage(object sender, PrintPageEventArgs ev)
    Metafile pageImage = new
    Metafile(m_streams[m_currentPageIndex]);
    // Adjust rectangular area with printer margins.
    Rectangle adjustedRect = new Rectangle(
    ev.PageBounds.Left - (int)ev.PageSettings.HardMarginX,
    ev.PageBounds.Top - (int)ev.PageSettings.HardMarginY,
    ev.PageBounds.Width,
    ev.PageBounds.Height);
    // Draw a white background for the report
    ev.Graphics.FillRectangle(Brushes.White, adjustedRect);
    // Draw the report content
    ev.Graphics.DrawImage(pageImage, adjustedRect);
    // Prepare for the next page. Make sure we haven't hit the end.
    m_currentPageIndex++;
    ev.HasMorePages = (m_currentPageIndex < m_streams.Count);
    Thank you very much for this wonderful tutorial. :)

  • Print report directly to printer without acknowledgement

    I'm running reports 9i.
    I can successfully print a report directly to a printer but how do I stop a window poping up displaying the "Oracle Reports Job Status"
    Thanks

    I have a very similar problem, not being able to print a report directly to the printer.
    But I am calling Crystal Reports v8.5 from VB6.  I have tried the  suggested code:
    report.PrintOut(prompt user, numberofCopy, collated, startpage, endpage)
    but get a "type mismatch" compiler error  with "PrintOut" highlighted when compiling, eventhough the inline help shows this method and matching arguments.
    I wonder if I have the correct DLL referenced.
    This report runs fine thru the preview window, but since this is a series of reports about 100 pages, don't really want the user to have to specify print dozens of times.
    Thanks,
    Gene

  • Fields missing while printing crystal reports !!

    Hello everyone
    I have a crystal report application in VB.NET 2005, which gets the values of a field from the database and supports printing of the report in the following formats
    1. pdf
    2. directly to a printer - printout
    When i export the report using reportdocument to pdf , all the fields are getting printed : Normal - As expected
    But when i print the report directly using PrintToPrinter method,i am not able to print some of the fields. i.e some of the entries are missing in that report printout
    Can someone guess what could be the problem ???
    Are there any limitations / preconfigurations that needs to be done apart from setting page size,margin before using the PrintToPrinter method
    Regards
    Srivatsa

    OK, a few incongruencies here:
    I'm using the version of the Crystal Reports that ships along with the Visual Studio.NET 2005.
    - that would make is CR 10.2
    We have also tried applying the latest service packs crxir2_sp4_full_build
    - So SP 4 for CR XI release 2 would not do you much good as per above (if you are indeed using CR 10.2(?))
    - How did you get to the crxir2_sp4_full_build? This is in a gated section of the SAP website. The only publically available SP 4 for CR XI r2 is "incremental... If you did apply crxir2_sp4_full_build, then you are working with CR XI r2 now...
    The behavior is seen in the web application and the behavior is seen both in the dev and deployment system.
    - So this does not work anywhere? If so, why bother going to deployment?
    Also i tried exporting to pdf soon before / after printing. But the fields are present in the pdf and not on the printouts
    - Confirm that you do see the fields on an exported PDF and when you print the PDF you get a blank printout?
    More clarification needed:
    We need to be absolutely clear on what version of Crystal Reports you are using. Open your .NET project, go to your references and look for CrystalDecisions.Crystalreports.Engine.dll. What version is this assembly?
    Also, please answer the rest of the questions above.
    Ludek

  • Print report directly to printer using RUN_PRODUCT in Forms6i

    Hi all,
    I would like to have information regarding print any .rdf directly to printer from form 6i using RUN_PRODUCT.
    I got help from Form Builder Help option and tried following coding in form
         DECLARE
         PL_ID                    PARAMLIST;
         printername          VARCHAR2(50);
         BEGIN
         PL_ID := GET_PARAMETER_LIST('WEIGHMENT');
              IF NOT ID_NULL(PL_ID) THEN
                   DESTROY_PARAMETER_LIST(PL_ID);
              END IF;
              PL_ID := CREATE_PARAMETER_LIST('WEIGHMENT');
              printername := '"'||'I.T Printer'||'"';
              Add_Parameter(pl_id, 'DESTYPE', TEXT_PARAMETER, PRINTER);
              Add_Parameter(pl_id, 'DESNAME', TEXT_PARAMETER, printername);
              Add_Parameter(pl_id, 'P_EQ_NBR', TEXT_PARAMETER, :weighment.eq_nbr);
              Add_Parameter(pl_id, 'P_WT_GKEY', TEXT_PARAMETER, :weighment.gkey);
              Run_Product(REPORTS, 'c:\wegt001r', ASYNCHRONOUS, RUNTIME, FILESYSTEM, PL_ID, NULL);
         EXCEPTION
              WHEN OTHERS THEN
              MESSAGE(SQLERRM);
         END;
    END IF;
    But report did not printed and following message received in Reports Background Engine
    Error submitting report [Thu May 07 18:49:23 2009] ...
    REP-0159: Syntax error on command line.
    Pls help.
    Thanks,
    Hassan

    Hi Heidi
    I have already tried printername := 'I.T Printer'; but result is same.
    This is also my default printer and I tried to add / remove the following coding
    Add_Parameter(pl_id, 'DESNAME', TEXT_PARAMETER, PRINTER);
    but in both cased I received the same error.
    I also tried to print thru HOST command as follows
    the_username := Get_Application_Property(USERNAME);
         the_password := Get_Application_Property(PASSWORD);
         the_connect := Get_Application_Property(CONNECT_STRING);
    the_command := 'rwrun60 report=c:\wegt001r.rdf userid= '||the_username||'/'||the_password||'@'||the_connect||' DESTYPE=Printer BACKGROUND=NO BATCH=YES ERRFILE=c:\reports\error.log LOGFILE=c:\reports\joblog.log p_eq_nbr='''||'TESTMKI'''||' p_wt_gkey=118306';
    Host( the_command );
    Host command displays correctly but no printing.
    I then change my command as follows
    the_command := 'rwrun60 report=c:\wegt001r.rdf userid=test/test@test DESTYPE=Printer BACKGROUND=NO BATCH=YES ERRFILE=c:\reports\error.log LOGFILE=c:\reports\joblog.log p_eq_nbr='''||'TESTMKI'''||' p_wt_gkey=118306'; and now report prints on printer.
    But I cannot hard coded the username, password and connect.
    Thanks,
    Hassan
    Edited by: Hassan Raza Khan Lodhi on May 7, 2009 6:55 PM

Maybe you are looking for

  • There is an error while romote debugging

    Hello, (BTW: I have german version and dont know if the names are correct written in english) I've created a (not small) application and use the "Enable debugging" attribute of my project. With AppBuilder it generates an EXE. This exe I've put on the

  • System preferences security crash

    Hi all, Everytime I try to open system preferences -> security i get a crash. I tried to reproduce the crash on a newly created user account - result crash again I tried to RESET System Preferences (you can reset almost program this way). Just mosey

  • Sorting for  storage type in LM12

    LM12 - change sort display so that alpha storage types with bin info displayed before numeric storage type and bin info. The standard LM12 shows sort order for storage type as  numeric storage types first then alpha storage types. But User is request

  • Dynamic sizing of Column Width

    Is there a way that the table columns can be dynamically adjusted widthwise in an RTF template ? I do not want my $Total to wrap around.

  • Not able to install Adobe CC desktopp App keep receiving another installer running error message

    Windows 8 PC I have used customer support several times to help with my issue and nothing seems to work. I am continously uninstalling and reinnstalling software with no solution to my problem. This only happens with Adobe, especially when there is a