3
我正在创建一个水晶报表@ c#程序,但是当我首先执行报表时它的工作情况,但是当我第二次执行同样的报表时,出现此错误。C#水晶报表参数超出范围异常
我使用视图来sql服务器来检索我的数据。
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();
其中是创建报告实例('crt')?它是在设计时加入f3的控件吗?尝试获取完整的异常调用堆栈并将其发布到此处。 *通常暗示代码不安全的脚本,用户可以注入恶意代码,如果在lblreferral或cbclientno中的文本是可编辑的* – dlatikay
感谢您的建议crt他们是水晶报告和f3是用于我使用的reportviewer的形式一个视图来获取所有这些数据,然后lblreferral是自动生成号码,而cbclient是仅存储clientno的组合框 –
确定您在第二次运行之前是否创建了一切的新实例,或者是否重新使用了现有实例? – dlatikay