The problem here is that your parameter names are
@cell1
and
@cell2
, but in your for loop, you are adding values to parameter names like
@cell[1]
and
@cell[2]
. You should remove the square brackets. Also, you should put the
ExecuteNonQuery
and
Close
method outside the loop, otherwise you execute the query before all parameters have values.
for (int i = 0; i < A.Length; i++)
{
cmd.Parameters.Add(new OleDbParameter("@cell" + i.ToString(), OleDbType.VarChar)).Value = A[i].Text;
}
cmd.ExecuteNonQuery();
con.Close();