如何计算更新表时受影响的行数,并在消息框中显示受影响的行数?
这是我更新表格的代码......
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
帮助将不胜感激...谢谢
答案 0 :(得分:3)
executeNonQuery方法返回受影响的行数。只需使用该号码并在消息框中显示即可。