生成报告时出现此错误。它说“索引(从零开始)必须大于或等于零且小于参数列表的大小。”
我该如何解决这个问题?谁能帮我这个?我是vb.net编程的新手。提前谢谢。
这是我的代码:
If String.IsNullOrEmpty(reportFilter) Then
daEmployee.SetWhereClause(String.Format("cdr_site_id = '{0}' AND cdr_datetime BETWEEN '{1}' AND '{2}' AND cdr_call_class_code = 'OUTGOING' AND cdr_call_type_id IN({3}) AND a.employee_id IN({4}) group by cdr_date,cdr_time,cdr_call_type_code ORDER BY employee_name", siteId, employeeId))
Else
daEmployee.SetWhereClause(String.Format("cdr_site_id = '{0}' AND cdr_datetime BETWEEN '{1}' AND '{2}' AND cdr_call_class_code = 'OUTGOING' AND cdr_call_type_id IN({3}) AND a.employee_id IN({4}) group by cdr_date,cdr_time,cdr_call_type_code ORDER BY employee_name", siteId, employeeId))
End If
答案 0 :(得分:0)
string.Format
需要五个替换参数,而您只通过了两个。您正在访问未通过的{2},{3},{4}索引参数。
daEmployee.SetWhereClause(String.Format("cdr_site_id = '{0}' AND cdr_datetime BETWEEN '{1}' AND '{2}' AND cdr_call_class_code = 'OUTGOING' AND cdr_call_type_id IN({3}) AND a.employee_id IN({4}) group by cdr_date,cdr_time,cdr_call_type_code ORDER BY employee_name", siteId, employeeId, another-three-parameters-here))