Crystal Report打印在服务器上 [英] Crystal Report Printing On server

查看:68
本文介绍了Crystal Report打印在服务器上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试从客户端系统打印在服务器上但不在客户端打印机上打印时,我想通过输入文本框打印基于ID的报告



I我正在使用此代码

i want to print report based on ID by entering in Text Box when i try to print from client system its printing on server but not on client printer

I am using this code

protected void Button3_Click(object sender, EventArgs e)
    {
//SqlCommand cmd = null;
        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 ");

        cmd.Connection = con;
        cmd.Parameters.Add("@report_type", SqlDbType.NVarChar).Value = TextBox1.Text;
        

        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();
        }
    }

推荐答案

检查这些

如何在没有预览或打印机对话框的情况下从ASP.NET直接将Crystal Reports打印到默认客户端打印机 [ ^ ]

在客户端打印Crystal Report在ASP.NET C# [ ^ ]
Check these
How to Directly Print a Crystal Reports to Default Client Printer from ASP.NET without Preview or Printer Dialog[^]
Printing Crystal Report on Client Side in ASP.NET C#[^]


这篇关于Crystal Report打印在服务器上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆