水晶报表,打印时出现错误提示:出现通信错误。将停止打印

meslog 2010-03-11 03:54:02
Crystal提示:
打印时出现错误提示:出现通信错误。将停止打印
请教各位 如何解决 ?
单击绑定数据,点击打印出错。
private void Search()
{
string ls_mname, ls_rectype;
string ls_lotno, ls_store;
string ls_matno, ls_itmno, ls_batch, ls_ordno, ls_supply, ls_statu;
DateTime ls_tkdat1, ls_tkdat2;
string ls_szno;

ls_mname = this.tb_mname.Text.Trim();
ls_rectype = this.ddlb_rectype.SelectedValue;
ls_lotno = this.tb_sku.Text.Trim();
ls_ordno = this.tb_ordno.Text.Trim();
ls_itmno = this.tb_itmno.Text.Trim();
ls_batch = this.tb_batch.Text.Trim();
ls_szno = this.tb_szno.Text.Trim();
ls_supply = "";
ls_statu = "";
ls_matno = this.tb_matno.Text.Trim();
ls_tkdat1 = Convert.ToDateTime(Convert.ToString(this.tb_tkdat1.Text.Trim()) + " 00:00:00");
ls_tkdat2 = Convert.ToDateTime(Convert.ToString(this.tb_tkdat2.Text.Trim()) + " 23:59:59");
if (ls_rectype == "ALL")
{
ls_rectype = "";
}

this.aERP_IN = new DALOG_ERP_IN();
DataTable data = this.aERP_IN.ReadData1(ls_ordno, ls_matno, ls_batch, ls_itmno, ls_supply, ls_statu, ls_mname, ls_rectype, ls_szno, ls_lotno, ls_tkdat1, ls_tkdat2);

CrystalReportSource1.ReportDocument.Load(Server.MapPath("view_Log_Erp_In_Report_new.rpt"));
CrystalReportSource1.ReportDocument.SetDataSource(data);
CrystalReportSource1.DataBind();
CrystalReportViewer1.ReportSource = CrystalReportSource1;
}
...全文
751 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
meslog 2010-03-12
  • 打赏
  • 举报
回复
可以使用,感觉问题在取数据那块。因为报表和查询数据是在一个页面。
public partial class Wms_Report_Log_Erp_In_Report : Log.SysClass.WebBase
{
private DALOG_ERP_IN aERP_IN;


protected void Page_Load(object sender, EventArgs e)
{
string ls_matno, ls_mname;

if (Session["matno"] != null)
{
ls_matno = Session["matno"].ToString();
ls_mname = Session["mname"].ToString();
tb_matno.Text = ls_matno;
tb_mname.Text = ls_mname;
Session.Remove("matno");
Session.Remove("mname");
}

if (!this.IsPostBack)
{
this.tb_tkdat1.Text = System.DateTime.Today.AddDays(-2).ToShortDateString();
this.tb_tkdat2.Text = System.DateTime.Today.ToShortDateString();
}
ReportDocument myReport = new ReportDocument();
string reportPath = Server.MapPath("view_Log_Erp_In_Report_new.rpt");
myReport.Load(reportPath);

//CrystalReport1 myReport = new CrystalReport1();

//绑定数据集,注意,一个报表用一个数据集。
myReport.SetDataSource(this.dtPrintData);
CrystalReportViewer1.ReportSource = myReport;

}
private DataTable dtPrintData
{
set
{
Cache["dtPrintData"] = value;
}
get
{
if (Cache["dtPrintData"] != null)
return (DataTable)Cache["dtPrintData"];
else
return null;
}
}

protected override void OnInit(EventArgs e)
{

}
private void Page_Unload(object sender, EventArgs e)
{
CrystalReportViewer1.Dispose();
}
private void Search()
{
string ls_mname, ls_rectype;
string ls_lotno, ls_store;
string ls_matno, ls_itmno, ls_batch, ls_ordno, ls_supply, ls_statu;
DateTime ls_tkdat1, ls_tkdat2;
string ls_szno;

ls_mname = this.tb_mname.Text.Trim();
ls_rectype = this.ddlb_rectype.SelectedValue;
ls_lotno = this.tb_sku.Text.Trim();
ls_ordno = this.tb_ordno.Text.Trim();
ls_itmno = this.tb_itmno.Text.Trim();
ls_batch = this.tb_batch.Text.Trim();
ls_szno = this.tb_szno.Text.Trim();
ls_supply = "";
ls_statu = "";
ls_matno = this.tb_matno.Text.Trim();
ls_tkdat1 = Convert.ToDateTime(Convert.ToString(this.tb_tkdat1.Text.Trim()) + " 00:00:00");
ls_tkdat2 = Convert.ToDateTime(Convert.ToString(this.tb_tkdat2.Text.Trim()) + " 23:59:59");
if (ls_rectype == "ALL")
{
ls_rectype = "";
}

this.aERP_IN = new DALOG_ERP_IN();
DataTable data = this.aERP_IN.ReadData1(ls_ordno, ls_matno, ls_batch, ls_itmno, ls_supply, ls_statu, ls_mname, ls_rectype, ls_szno, ls_lotno, ls_tkdat1, ls_tkdat2);

this.dtPrintData = data;

////使用报表对象加载报表
//ReportDocument myReport = new ReportDocument();
//string reportPath = Server.MapPath("view_Log_Erp_In_Report_new.rpt");
//myReport.Load(reportPath);

////CrystalReport1 myReport = new CrystalReport1();

////绑定数据集,注意,一个报表用一个数据集。
//myReport.SetDataSource(data);
//CrystalReportViewer1.ReportSource = myReport;

//CrystalReportSource1.ReportDocument.Load(Server.MapPath("view_Log_Erp_In_Report_new.rpt"));
//CrystalReportSource1.ReportDocument.SetDataSource(data);
//CrystalReportSource1.DataBind();
//CrystalReportViewer1.ReportSource = CrystalReportSource1;
// CrystalReportViewer1.DataBind();
}

protected void Ok_Click(object sender, EventArgs e)
{
this.Search();
}

protected void DataGrid1_SelectedIndexChanged(object sender, EventArgs e)
{

}
private void ToExcel(System.Web.UI.Control ctl)
{
Response.Charset = "GB2312";
Response.AppendHeader("Content-Disposition", "attachment;filename=" +
//System.DateTime.Now.ToString("yyyyMMddhhmmss") + "_" +
HttpUtility.UrlEncode(System.Text.Encoding.UTF8.GetBytes("入库单据查询_导出")) + ".xls");
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.ContentType = "application/ms-execl";
ctl.Page.EnableViewState = false;
System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new HtmlTextWriter(tw);
ctl.RenderControl(hw);
Response.Write(tw.ToString());
Response.End();
}
protected void Zp_Click(object sender, EventArgs e)
{

}
protected void Exit_Click(object sender, EventArgs e)
{

}
protected void Save_Click(object sender, EventArgs e)
{
this.ToExcel(DataGrid1);
}
protected void Print_Click(object sender, EventArgs e)
{
ConfigureCrystalReports();
}
protected void Find_Click(object sender, EventArgs e)
{
string ls_url;

ls_url = Request.UrlReferrer.ToString();
Session["url"] = ls_url;
this.Response.Redirect("../../matno.aspx");
}
protected void ddlb_rectype_Init(object sender, EventArgs e)
{

IDAL objDAL = DALFactory.GetDBO();
objDAL.Open();
string cmdText = "select * from drp_tbl_ywsxb where flag in ('I','IO','IIO') order by [order] desc";
DataSet objSet = objDAL.DataAdapter(CommandType.Text, cmdText, "drp_tbl_ywsxb");
objDAL.Close();

this.ddlb_rectype.DataSource = objSet.Tables[0].DefaultView;
this.ddlb_rectype.DataTextField = "lname";
this.ddlb_rectype.DataValueField = "code";
this.ddlb_rectype.DataBind();
}
mb_1985 2010-03-11
  • 打赏
  • 举报
回复
确认\\pc1\printer可以使用,你可以自己开个空的word文档单独测下打印机
meslog 2010-03-11
  • 打赏
  • 举报
回复
是工具条。
选了正确的打印机,不过是通过网络共享的。如\\pc1\printer
阿泰 2010-03-11
  • 打赏
  • 举报
回复
是点击工具条上的打印按钮吗?
选了正确的打印机,且打印机安装正确吗?

4,818

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 图表区
社区管理员
  • 图表区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧