I need to bypass the print process of crystal report. With so much searching over the net I found these codes. Its printing in VS 2005 Team Edition for Developers but when I publish it to the IIS 5.1 its not printing. Any tips?


using System.Web.UI;using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
public partial class _Default : System.Web.UI.Page
{
private ReportDocument northwindCustomersReport;
private void ConfigureCrystalReports()
{
northwindCustomersReport = new ReportDocument();

string reportPath = Server.MapPath("CrystalReport2.rpt");

northwindCustomersReport.Load(reportPath);

ConnectionInfo connectionInfo = new ConnectionInfo();

connectionInfo.ServerName = "servername";

connectionInfo.DatabaseName = "dbname";

connectionInfo.UserID = "userid";

connectionInfo.Password = "password";

SetDBLogonForReport(connectionInfo,northwindCustomersReport);

CrystalReportViewer1.ReportSource = northwindCustomersReport;

northwindCustomersReport.PrintToPrinter(1, false, 1, 1);

}


private void Page_Init(object sender, EventArgs e)

{
ConfigureCrystalReports();
}


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;

table.ApplyLogOnInfo(tableLogonInfo);
}
}
}