2015-12-28 150 views
0

我在生成報告時收到此錯誤。它說「索引(基於零)必須大於或等於零並小於參數列表的大小。」索引(基於零)必須大於或等於零且小於參數列表(VB.NET)的大小

我該如何解決這個問題?誰能幫我這個?我是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 
+2

你'string.Format'需要5個參數({0} - {4}),而你只傳遞2. –

回答

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)) 
+0

僱員通過三個,將採取的位置參數後,{2},{ 3},{4}。 –

相關問題