我進口excelsheet到SQLSERVER數據庫中讀取數據,但有三列在Excel:指數數組的邊界之外,同時從excelsheet
id|data|passport
我想確保所有護照開始用字母我我得到 錯誤的:
if (a[0]>= 'A' && a[0] <= 'Z' && a[0] !='0')
錯誤:
Index was outside the bounds of the array.
for (int i1 = 0; i1 < dt7.Rows.Count; i1++)
{
if (dt7.Rows[i1]["passport"]==null)
{
dt7.Rows[i1]["passport"] = 0;
}
string a = Convert.ToString(dt7.Rows[i1]["passport"]);
//char a1 = a[0];
if (a[0]>= 'A' && a[0] <= 'Z' && a[0] !='0')
{
Label12.Text = "CAPITAL";
break;
}
else
{
Label12.Text = "notgood";
flag = flag + 1;
}
使用斷點,並得到了dt7.Rows [I1 ] [「護照」]有價值「k526562」對象{字符串} – Arbaaz