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.