Reputation: 243
how do i count the number of rows that are affected when I updated a table, and display the number of affected rows in a message box ??
here is my code for updating the table ...
For Each row As DataGridViewRow In DataGridView1.Rows
req = row.Cells(Column1.Name).Value
If row.Cells("Column1").Value = True Then
Dim sql2 As String = "UPDATE EquipmentDetail SET Requested = '" & req & "' WHERE SerialNumber = '" & serials & "'"
cmd2.Connection = connection
cmd2.CommandText = sql2
cmd2.ExecuteNonQuery()
End If
Next
connection.Close()
End Sub
help would be appreciated ... thanks
Upvotes: 1
Views: 1499
Reputation: 4504
The executeNonQuery method returns the number of affected rows. Just use that number and show in a message box.
Upvotes: 3