![]() In conclusion, remove that line from your stored procedure, and you will now get a value indicating the number of rows affected by the statement. ![]() 0 GeraldOakham-9565 answered at 4:20 AM Hi, but after the backup it produces the ''EndExecuteNonQuery' cannot be called more than once for the same execution. That line is: SET NOCOUNT ON This line turns on the NOCOUNT feature of SQL Server, which "Stops the message indicating the number of rows affected by a Transact-SQL statement from being returned as part of the results" and therefore it makes the stored procedure always to return -1 when called from the application (in my case a web application). EndExecuteNonQuery ' at the end of the backup section, And what should that be good for The execution automatically ends when the backup has finished. This sounds very nice, but whenever you use the SQL Server 2005 IDE or Visual Studio to create a stored procedure it adds a small line that ruins everything. ExecuteNonQuery returns the number of rows affected by the statement. So if you want to run an update, delete, or insert statement, you should use the ExecuteNonQuery. Whenever you want to execute an SQL statement that shouldn't return a value or a record set, the ExecuteNonQuery should be used.
0 Comments
Leave a Reply. |