![](/img/trans.png)
[英]How to print multiple instance of crystal report using single Crystal Report Viewer in c#
[英]How to take direct print of crystal report using C# code
我正在嘗試直接打印我的報告。 我制作了一個對話框來設置打印機設置,我使用這些設置進行打印,但是出現了這樣的錯誤:
at PrinttoPrinter line "missing parameter value "
這是我的代碼:
ReportDocument rp = new ReportDocument();
rp.Load(@"my source");
PrinterSettings settings = new PrinterSettings();
PrintDialog pdialog = new PrintDialog();
if (pdialog.ShowDialog() == DialogResult.OK)
{
settings = pdialog.PrinterSettings;
}
AttendenceR r = new AttendenceR();
SqlConnection con = new SqlConnection();
con.ConnectionString = "My connection string";
da = new SqlDataAdapter("Here is my query");
DataSet ds = new DataSet();
da.Fill(ds, "StudentDetails");
rp.SetDataSource(ds);
rp.PrintToPrinter(settings, new PageSettings() { }, false);
我建議運行 ExportToDisk 以首先確保您可以生成一個好的 PDF,然后再進行打印。 我懷疑 PDF 不會生成。 您可以使用 SetParameterValue 方法添加參數。 您可以檢查 .rpt.cs 代碼隱藏文件以查看每個參數的索引。
rp.SetParameterValue(0, "Parameter Value");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.