Click here to Skip to main content
13,198,068 members (50,381 online)
Rate this:
Please Sign up or sign in to vote.
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();
        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);
        if (dt.Rows.Count > 0)
            ReportDocument Report = new ReportDocument();
            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;
            CrTables = Report.Database.Tables;
            foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
                crtableLogoninfo = CrTable.LogOnInfo;
                crtableLogoninfo.ConnectionInfo = crConnectionInfo;
            Report.PrintToPrinter(1, true, 1, 1);
Posted 1-Dec-12 1:40am
anglo0072 2-Dec-12 9:13am
it happens when the datasource provided returns null at the time of printing.
You need to make sure that the datasource provided has continuous data feed to viewer. You can repopulate the report data just before print.
and i hope you have set autopostback true of you textbox

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171020.1 | Last Updated 31 Oct 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100