您的位置:首页 > 其它

水晶报表参数赋值时出现异常: 无效的索引

2015-01-19 14:36 239 查看
同时出现这个错误,我马上就想到,

1.参数设置是否争取 ;于是马上仔细的检查一遍参数都设置了吗  咿没错

2.我未更新 报表模板了 于是乎打开资源管理器,把该报表模板复制并更新debug/bin 目录下

运行,

 还是出错呀?

于是求助了领导发现我的参数设置有问题

创建了一个参数字段count1 (字符串) 在报表中有个small 和big 参数引用了同一个count 参数字段

于是重新创建参数字段small  and big 并且在模板上分别引用 如下图所示

运行OK

!success 

</pre></p><p><pre name="code" class="csharp"><span style="font-size:18px;">代码:
private void commonfunction()
{
#region 设置参数

doc.SetParameterValue("year", getDateByStr(1,this.date.Text));
doc.SetParameterValue("month", getDateByStr(2, this.date.Text));
doc.SetParameterValue("day", getDateByStr(3, this.date.Text));
doc.SetParameterValue("num", this.num.Text);
doc.SetParameterValue("unit", this.cbUnit.Text + " 款");
doc.SetParameterValue("big1", this.txtBig.Text);
doc.SetParameterValue("small", moneyFormat(this.txtSmall.Text) + "元");

#endregion

this.crystalReportViewer1.ReportSource = doc;

}</span>


 

注意每个参数的名称 与该参数设置Name属性值要保持一致  否则会出现异常
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  WinForm