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

来源:互联网 发布:泰安东华软件怎么样 编辑:程序博客网 时间:2024/05/18 01:13


同时出现这个错误,我马上就想到,

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属性值要保持一致  否则会出现异常






0 0
原创粉丝点击