title: What is the fastest way to insert values from datagridview to mysql database
body: <p>I have a vb.net system and I want to insert 10,000 or more records from datagridview to mysql database. But it takes 8mins for 10,000 records when i tried this</p>
  
  <pre><code>For i As Integer = 0 To DataGridView1.Rows.Count - 1
  
                          Dim queryInsert As String = "INSERT INTO tbl_shipdetails (ship_date, item_type, item_code, imei1, imei2)" &amp; _
                                                      "VALUES('" &amp; DataGridView1.Rows(i).Cells(1).Value &amp; "','" &amp; DataGridView1.Rows(i).Cells(2).Value &amp; "','" &amp; DataGridView1.Rows(i).Cells(3).Value &amp; "','" &amp; DataGridView1.Rows(i).Cells(4).Value &amp; "','" &amp; DataGridView1.Rows(i).Cells(5).Value &amp; "')"
                          MySqlCmd = New MySqlCommand
                          MySqlCmd.Connection = Myconnect
                          MySqlCmd.CommandText = queryInsert
                          MySqlCmd.ExecuteNonQuery()
                      Next
  </code></pre>
  
  <p>I want to know if someone knows what is the fastest way to do this? can anyone please help me. I'm thinking of inserting the whole values in datagridview to mysql with just one insertion (like as bulk) and not using a loop but I don't know if it's possible. </p>
  
  <p>thanks in advance!</p>