Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I retrieve the number of rows affected from SQL Server to VB.NET?

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

like image 961
Kurusu Avatar asked Oct 19 '11 13:10

Kurusu


People also ask

How can I count the number of rows affected in SQL Server?

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.

How do you get the number of rows affected by a query?

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.

How do you count the number of rows in a SQL update?

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).

Which method returns the number of rows affected by the command in asp net?

ExecuteNonQuery - returns the number of rows affected.


1 Answers

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)
like image 149
Sai Kalyan Kumar Akshinthala Avatar answered Sep 30 '22 06:09

Sai Kalyan Kumar Akshinthala