打印报告中的错误 [英] Error in print report
本文介绍了打印报告中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有2个问题:
当我单击报告的打印"按钮时,出现以下错误.
无效的报告文件路径.从这行开始:rd.PrintToPrinter(1,false,0,1);
我该怎么办?
为了在crystalreprot查看器中的asp.net中打印报告,当我刷新页面时,打印"按钮不能正常工作,为什么?
Hi,
I have 2 questions:
When I click on print button for my report, I recive following error.
Invalid report file path. from this line:rd.PrintToPrinter(1, false, 0, 1);
What do i do?
And for printing my report in asp.net in crystalreprot viewer, when I refresh my page, print button does not work properly, why?
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
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;
using CrystalDecisions.Reporting;
public partial class mojavez_Report : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString);
ReportDocument rd = new ReportDocument();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
getdata();
}
}
void getdata()
{
con.Open();
SqlCommand com = new SqlCommand("SELECT DISTINCT MajorName FROM Majores ", con);
SqlDataAdapter da = new SqlDataAdapter(com);
DataTable dt = new DataTable();
da.Fill(dt);
DropDownList3.DataSource = dt;
DropDownList3.DataTextField = "MajorName";
DropDownList3.DataValueField = "MajorName";
DropDownList3.SelectedIndex = DropDownList3.Items.Count + 1;
DropDownList3.DataBind();
SqlCommand com1 = new SqlCommand("SELECT DISTINCT City FROM DrInfo ", con);
SqlDataAdapter da1 = new SqlDataAdapter(com1);
DataTable dt1 = new DataTable();
da1.Fill(dt1);
DropDownList1.DataSource = dt1;
DropDownList1.DataTextField = "City";
DropDownList1.DataValueField = "City";
DropDownList1.SelectedIndex = DropDownList1.Items.Count + 1;
DropDownList1.DataBind();
con.Close();
}
protected void Button1_Click(object sender, EventArgs e)
{
rd.Load(Server.MapPath("MojavezReport.rpt"));
rd.SetDatabaseLogon("", "", @".", "DrInfo ,Majores");
rd.SetParameterValue("dname", TextBox1.Text);
rd.SetParameterValue("startdate", TextBox2.Text);
rd.SetParameterValue("dnum", TextBox3.Text);
rd.SetParameterValue("sex", DropDownList4.Text);
rd.SetParameterValue("city", DropDownList1.Text);
rd.SetParameterValue("smarried", DropDownList2.Text);
rd.SetParameterValue("majorename", DropDownList3.Text);
CrystalReportViewer1.ReportSource = rd;
}
protected void Button2_Click(object sender, EventArgs e)
{
rd.PrintOptions.PrinterName = "HP LaserJet M1522n";
rd.PrintToPrinter(1, false, 0, 1);
CrystalReportViewer1.PrintReport();
}
推荐答案
您在该行中的语法似乎没问题:
http://msdn.microsoft.com/en-us/library/ms226031%28v = vs.90%29.aspx [ ^ ]
您是否已检查打印机是否存在:
http://msdn.microsoft.com/en-us/library/ms225960%28v = vs.80%29.aspx [ ^ ]
请尝试任何操作,然后它将使用默认打印机.
祝您好运:)
Your syntax in that line seems to be ok:
http://msdn.microsoft.com/en-us/library/ms226031%28v=vs.90%29.aspx[^]
HAve you checked that the printer exists:
http://msdn.microsoft.com/en-us/library/ms225960%28v=vs.80%29.aspx[^]
Try nothing instead, then it will use the default printer.
So good luck to you :)
这篇关于打印报告中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文