Using Crystal Reports PrintToPrinter command with ASP.Net

Last Reply on Dec 02, 2012 10:45 PM By Mudassar

Posted on Dec 02, 2012 10:45 PM

i am using this code for printing when i try printing from client system its printing on server printer .  Helpp

 

 DateTime curdate = Convert.ToDateTime(TextBox1.Text);
    
        SqlDataAdapter da = null;
        DataTable dt = new DataTable();
        DataTable dt1 = new DataTable();
        con.Open();
        SqlCommand cmd = new SqlCommand("SELECT * FROM Transactions where report_type = @report_type AND  dateadd(dd, datediff(dd,0, [R_date]), 0) = @R_date");
        cmd.Connection = con;
        cmd.Parameters.Add("@report_type", SqlDbType.NVarChar).Value = DropDownList1.SelectedValue;
        cmd.Parameters.Add("@R_date", SqlDbType.DateTime).Value = curdate.Date;
        da = new SqlDataAdapter(cmd);
        dt.Clear();
        da.Fill(dt);
        if (dt.Rows.Count > 0)
        {

            ReportDocument Report = new ReportDocument();
            Report.Load(Server.MapPath("~/Report.rpt"));
            Report.SetDataSource(dt);
            TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
            TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
            ConnectionInfo crConnectionInfo = new ConnectionInfo();
            Tables CrTables;
             Report.SetDatabaseLogon("sa", "123456789", @"TRAINING-ROOM-8", "newMreport");
            CrystalReportViewer1.ReportSource = Report;
            CrystalReportViewer1.ReportSource = Report;
            CrystalReportViewer1.DataBind();
            CrTables = Report.Database.Tables;
            foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
            {
                crtableLogoninfo = CrTable.LogOnInfo;
                crtableLogoninfo.ConnectionInfo = crConnectionInfo;
                CrTable.ApplyLogOnInfo(crtableLogoninfo);
            }

            Report.Refresh();
            Report.PrintToPrinter(1, true, 1, 1);
            con.Close();
        }
    }

 

I agree, here is the link: https://www.e-iceblue.com/Introduce/spire-office-for-net-free.html