Basically I'm retrieving all the data in my program through runtime, I was wondering how will I retrieve the number of rows affected after an update so I could prompt the user about it through VB.NET
What I'm actually doing is, after an update, if there are no other rows updated then the user can no longer click on the button
Usage. SQL Server @@ROWCOUNT is a system variable that is used to return the number of rows that are affected by the last executed statement in the batch.
MySQL ROW_COUNT() can be used to get the total number of rows affected by MySQL query. To illustrate it we are creating a procedure with the help of which we can insert records in a table and it will show us how many rows have been affected.
Use the COUNT aggregate function to count the number of rows in a table. This function takes the name of the column as its argument (e.g., id ) and returns the number of rows for this particular column in the table (e.g., 5).
ExecuteNonQuery - returns the number of rows affected.
By using ExecuteNonQuery, it will returns no rows, any output parameters or return values mapped to parameters are populated with data.
For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command.
EDIT:
You can prompt the User like
Dim RowsAffected as Integer = Command.ExecuteNonQuery()
MsgBox("The no.of rows effected by update query are " & RowsAffected.ToString)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With