title: VB.Net SQL insert from datagrid
body: <p>I am currently building an application whereby a user inputs data into a grid and this is then inserted into a SQl table.
  However i am having issues getting it to insert more than the top row. I get an error stating too many parameters have been declared for the procedure.
  am trying to execute a loop with the insert occuring for each row. 
  When run the top row is inserted but anything else is ignored</p>
  
  <pre><code>    For i = 0 To dgvRI.Rows.Count - 1
              sqlRI.CommandText = "dbo.vb_insert"
              sqlRI.CommandType = CommandType.StoredProcedure
              sqlRI.Parameters.Add("@accid", SqlDbType.VarChar).Value = accid
              sqlRI.Parameters.Add("@rnum", SqlDbType.Int).Value = dgvRI.Rows(i).Cells(0).Value
              sqlRI.Parameters.Add("@rilim", SqlDbType.Decimal).Value = dgvRI.Rows(i).Cells(1).Value
              sqlRI.Parameters.Add("@riatt", SqlDbType.Decimal).Value = dgvRI.Rows(i).Cells(2).Value
              sqlRI.Parameters.Add("@rishare", SqlDbType.Decimal).Value = dgvRI.Rows(i).Cells(3).Value
              sqlRI.Parameters.Add("@rname", SqlDbType.VarChar).Value = dgvRI.Rows(i).Cells(4).Value
              sqlRI.Parameters.Add("@bname", SqlDbType.VarChar).Value = dgvRI.Rows(i).Cells(5).Value
              sqlRI.Parameters.Add("@type", SqlDbType.VarChar).Value = dgvRI.Rows(i).Cells(6).Value
              sqlRI.Parameters.Add("@cov", SqlDbType.VarChar).Value = dgvRI.Rows(i).Cells(7).Value
              sqlRI.Parameters.Add("@prop", SqlDbType.VarChar).Value = dgvRI.Rows(i).Cells(8).Value
              sqlRI.Parameters.Add("@loc", SqlDbType.VarChar).Value = dgvRI.Rows(i).Cells(9).Value
              sqlRI.Parameters.Add("@con", SqlDbType.VarChar).Value = dgvRI.Rows(i).Cells(10).Value
              sqlRI.Parameters.Add("@prem", SqlDbType.Decimal).Value = dgvRI.Rows(i).Cells(11).Value
              sqlRI.Parameters.Add("@curr", SqlDbType.VarChar).Value = dgvRI.Rows(i).Cells(12).Value
              i += sqlRI.ExecuteNonQuery()
          Next
      Catch ex As Exception
          MessageBox.Show(ex.Message)
      End Try
  </code></pre>