我正在创建一个 Crystal 报表 @c# 程序,但是当我第一次执行该报表时它正常工作但是当我第二次执行相同的报表时我遇到了这个错误。
我使用 View 到 sql server 来检索我的数据。
cmd = new SqlCommand("Select * From referral where referralNo = '" +
lblReferral.Text + "' and clientNo = '" + cbClientNo.Text + "'", con);
cmd.CommandType = CommandType.Text;
da.SelectCommand = cmd;
da.Fill(ds, "referral");
rp.SetDataSource(ds);
f3.crt.ReportSource = rp;
f3.Show();
rp.Close();
我有这个错误。
An unhandled exception of type 'System.ArgumentOutOfRangeException'
occurred in System.Windows.Forms.dll
Additional information: Index 0 is out of range.
那么这些是实例
CrystalReport1 rp = new CrystalReport1();
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
reportViewer f3 = new reportViewer();
最佳答案
我找到了我的问题的答案,它提示参数异常,因为程序,我通过 form.Show()
而不是 form.ShowDialog()
调用表单.
关于C# Crystal 报表参数超出范围异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45869469/