Print Page | Close Window

Printing Report

Printed From: Crystal Reports Book
Category: Crystal Reports .NET 2003
Forum Name: Writing Code
Forum Discription: .NET 2003 programming API, report integration
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=4942
Printed Date: 19 May 2024 at 5:36am


Topic: Printing Report
Posted By: cardpogi
Subject: Printing Report
Date Posted: 05 Dec 2008 at 7:23am
I wanted to see if I can get some help with this I'm trying to print report with a button and sending a parameter with the same button. My Code is the following:

public void imprimir_reporte(string rutareporte)

    {   
        String error = "Impresion Fallida, Error: ";
        try
        {
        ReportDocument reportecasos = new ReportDocument();    
            SetDBLogonForReport(connectionInfo,reportecasos);
            reportecasos.Load(rutareporte);
            reportecasos.SetParameterValue("CodCaso", txtCodigoCaso.Text.Trim());
            reportecasos.PrintToPrinter(1, false, 0, 0);
            ShowMessage("Impresion Excitosa", 5);
        }
        catch (Exception ex)
        {
            ShowMessage(error += ex.Message,3);
        }
}
    protected void BotonRecibo_Click(object sender, EventArgs e)
    {
        imprimir_reporte("ReciboCasos.rpt");
    }
    protected void BotonBitacora_Click(object sender, EventArgs e)
    {
        imprimir_reporte("Expediente Seguimiento Caso.rpt");
    }
    private void SetDBLogonForReport(ConnectionInfo connectionInfo, ReportDocument reportDocument)
    {
        Tables tables = reportDocument.Database.Tables;
        foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
        {
            TableLogOnInfo tableLogonInfo = table.LogOnInfo;
            tableLogonInfo.ConnectionInfo = connectionInfo;
            connectionInfo.DatabaseName = "sisaa";
            connectionInfo.UserID = "admin";
            connectionInfo.Password = "dida";
            table.ApplyLogOnInfo(tableLogonInfo);
        }
    }


But eveytime I try to print it say's it cant find the report path, and I'm sure this is the correct report path because I have tried it in other part's of my program various times.



Replies:
Posted By: cardpogi
Date Posted: 08 Dec 2008 at 8:30am
Anyone?



Print Page | Close Window