Hi,

I have this code where I add 20 parameters to the OleDbCommand but for some reason I only get 1 record inserted, why is this?

VB Code:
  1. OleDbCommand dbcommand = new OleDbCommand(sql2, conn2);
  2.  
  3.                             int Tablecount = 0;
  4.                             foreach (DataSet ds in TempDataSet)
  5.                             {
  6.                                 //foreach (string s in TempColumnName)
  7.                                 //{
  8.                                 string s = "@" + TempColumnName[Tablecount];
  9.                                 foreach (DataRow dr in ds.Tables[0].Rows)
  10.                                 {
  11.                                     //dbcommand.Parameters.Add(s, ds.Tables[0].Rows[ds.Tables[0].Rows.IndexOf(dr)][0]);
  12.                                     dbcommand.Parameters.AddWithValue(s, ds.Tables[0].Rows[ds.Tables[0].Rows.IndexOf(dr)][0]);
  13.                                 }
  14.                                 //}
  15.                                 Tablecount++;
  16.                             }
  17.  
  18.                             dbcommand.ExecuteNonQuery();

Thanks Loftty,