问题描述
我想直接打印报告打印机而不显示水晶报告预览
所以我用的是代码,但我收到消息告诉我缺少参数值
此代码:
我的尝试:
I want print report directly to printer without show preview of crystal report
so i was used thid code but i got message tell me that missing parameter values
this code:
What I have tried:
public void PrintReport()
{
ReportDocument cryRpt = new ReportDocument();
cryRpt.Load(@C:\ Users \USER \Desktop \ my Activies \OldMurbad \ Murbad \ Murbad \ RPT \PrintInvoice。 rpt);
cryRpt.SetParameterValue(@ IDorder,txtInvoiceNo.Text);
TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
表格CrTables;
crConnectionInfo.ServerName = @DELL\SQLEXPRESS;
crConnectionInfo.DatabaseName = @Murbad1;
crConnectionInfo.UserID = @IBRA;
crConnectionInfo.Password = @IBRA;
CrTables = cryRpt.Database.Tables;
foreach(CrTables中的CrystalDecisions.CrystalReports.Engine.Table CrTable)
{
crtableLogoninfo = CrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
CrTable.ApplyLogOnInfo(crtableLogoninfo);
}
cryRpt.Refresh();
cryRpt.PrintToPrinter(1,true,0,0);
}
public void PrintReport()
{
ReportDocument cryRpt = new ReportDocument();
cryRpt.Load(@"C:\Users\USER\Desktop\my Activies\OldMurbad\Murbad\Murbad\RPT\PrintInvoice.rpt");
cryRpt.SetParameterValue("@IDorder", txtInvoiceNo.Text);
TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
Tables CrTables;
crConnectionInfo.ServerName = @"DELL\SQLEXPRESS";
crConnectionInfo.DatabaseName = @"Murbad1";
crConnectionInfo.UserID = @"IBRA";
crConnectionInfo.Password = @"IBRA";
CrTables = cryRpt.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
crtableLogoninfo = CrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
CrTable.ApplyLogOnInfo(crtableLogoninfo);
}
cryRpt.Refresh();
cryRpt.PrintToPrinter(1, true, 0, 0);
}
推荐答案
这篇关于缺少参数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!