I am importing excelsheet into sqlserver database but there are three columns in excel:
id|data|passport
I want to make sure that all passports start with an alphabet i am getting
error at:
if (a[0]>= 'A' && a[0] <= 'Z' && a[0] !='0' )
Error:
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;
}
Why not just modify your condition like this