title: VB.Net insert multiple records
body: <p>I have several rows in DataGridView control. And i want to insert each row into database. I tried like this. But it gives error that parameter is already added. How to add parameter name once and then add values each time and execute it each time?</p>
  
  <pre><code>    Using connection As New SqlCeConnection(My.Settings.databaseConnectionString)
          Using command As New SqlCeCommand("INSERT INTO table_master(item, price) VALUES(@item, @price)", _
                                          connection)
  
              connection.Open()
  
              For Each r As DataGridViewRow In dgvMain.Rows
                  If (Not String.IsNullOrWhiteSpace(r.Cells(1).Value)) Then
                      command.Parameters.AddWithValue("@item", r.Cells(1).Value.Trim)
                      command.Parameters.AddWithValue("@price", r.Cells(2).Value)
  
  
                      command.ExecuteNonQuery()
                  End If
              Next
  
          End Using
      End Using
  </code></pre>