title: I am facing an issue during inserting data through datagrid in database
body: <p>when i insert data through datagrid in a database data's are inserting but an additional blank row is also coming in the data base</p>
  
  <p>My Code:-</p>
  
  <p>Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click</p>
  
  <pre><code>    con()
  
      Dim SNo As String
      Dim Name As String
      Dim Address As String
  
      For i As Integer = 0 To Me.DataGridView1.Rows.Count - 1
  
          If Me.DataGridView1.Rows.Count = 0 Then
  
              Exit For
  
          End If
  
          SNo = Me.DataGridView1.Rows(i).Cells(0).Value
          Name = Me.DataGridView1.Rows(i).Cells(1).Value
          Address = Me.DataGridView1.Rows(i).Cells(2).Value
  
  
          Dim sql As String = "insert into Customer(SNo,Name,Address)values('" &amp; SNo &amp; "','" &amp; Name &amp; "','" &amp; Address &amp; "')"
  
          cmd = New SqlCommand(sql, cn)
  
          cmd.ExecuteNonQuery()
  
      Next
  
      MsgBox("Inserted")
  
      cn.Close()
  
  
  End Sub
  </code></pre>