计算受影响的行数并在消息框中显示该数字

时间:2012-01-08 19:47:50

标签: vb.net numbers rows

如何计算更新表时受影响的行数,并在消息框中显示受影响的行数?

这是我更新表格的代码......

    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

帮助将不胜感激...谢谢

1 个答案:

答案 0 :(得分:3)

executeNonQuery方法返回受影响的行数。只需使用该号码并在消息框中显示即可。