C# 在c语言中打印crystal report时,打印机错误“等待装入纸张”#
C# 在c语言中打印crystal report时,打印机错误“等待装入纸张”#,c#,printing,crystal-reports,C#,Printing,Crystal Reports,我正在从这个错误中恢复过来。我正在按一下按钮打印收据。但当命令转到默认打印机时,显示以下打印错误。 使用其他应用程序打印时没有错误。我正在使用c#和MS Access数据库。下面是我的打印代码 //Button Click Code public void PrintOPDReceipt() { string ReportPath; using (ReportDocument rptDc = new
我正在从这个错误中恢复过来。我正在按一下按钮打印收据。但当命令转到默认打印机时,显示以下打印错误。
使用其他应用程序打印时没有错误。我正在使用c#和MS Access数据库。下面是我的打印代码
//Button Click Code
public void PrintOPDReceipt()
{
string ReportPath;
using (ReportDocument rptDc = new ReportDocument())
{
using (OleDbConnection Con = Connections.Create())
{
Con.Open();
using (DataSet OPDDataSet = new OPDDataSet())
{
DataTable Dt = new DataTable();
Dt.Columns.Add("Query", typeof(string));
Dt.Rows.Add("select * from OPDRegistration where Id = " + SetId + "");
Dt.Rows.Add("select * from CompanyIdentity");
Dt.Rows.Add("Select * from ConsultantMaster where Id = (Select ConsultantId from OPDRegistration where Id = " + SetId + ")");
using (DataSet Ds = GetPrintDetails(Dt, Con))
{
OPDDataSet.Tables["OPDRegistration"].Merge(Ds.Tables[0]);
OPDDataSet.Tables["CompanyIdentity"].Merge(Ds.Tables[1]);
OPDDataSet.Tables["ConsultantMaster"].Merge(Ds.Tables[2]);
ReportPath = Environment.CurrentDirectory + "\\Reports\\rptOPDReceipt.rpt";
rptDc.Load(ReportPath);
rptDc.SetDataSource(OPDDataSet);
rpvReportViewer.ReportSource = rptDc;
rpvReportViewer.Refresh();
rptDc.PrintToPrinter(Convert.ToInt32(Connections.GetGlobalSettings.Rows[0]["ReceiptPrintCopies"]), false, 0, 0);
}
}
}
}
}
//This how I am getting data from the database
private DataSet GetPrintDetails(DataTable dt, OleDbConnection Con)
{
string Query = string.Empty;
using (DataTable NewDt = dt)
{
using (DataSet ds = new DataSet())
{
foreach(DataRow Rw in NewDt.Rows)
{
Query = Rw[0].ToString();
using (OleDbCommand cmd = new OleDbCommand(Query, Con))
{
using (OleDbDataAdapter adp = new OleDbDataAdapter())
{
using (DataTable DataDt = new DataTable())
{
adp.SelectCommand = cmd;
adp.Fill(DataDt);
ds.Tables.Add(DataDt);
}
}
}
}
return ds;
}
}
}
注意打印机没有问题,因为它可以与其他应用程序配合使用。任何帮助都将不胜感激。谢谢。尝试在rpvReportViewer.Refresh()之前设置纸张大小@安东尼奥坎波斯感谢您的评论,但它不起作用。