I'm trying to create a Scheduled Task AddIn based on a Stored Procedure, but whatever I return from my stored procedure, ExecuteNonQuery always returns -1
This means that the sceduled task always show as Error.
What could be wrong?
RETURN 1;
I'm trying to create a Scheduled Task AddIn based on a Stored Procedure, but whatever I return from my stored procedure, ExecuteNonQuery always returns -1
This means that the sceduled task always show as Error.
What could be wrong?
Have you tried to use Database.ExecuteScalar instead?
/Morten
I am pretty sure that ExecuteNonQuery always returns the number of affected rows or -1 for non-DML statements, and does not give you the return value. So, with a procedure like
SET NOCOUNT OFF
DELETE FROM SomeTable where ID < 10
you will get the number of rows affected by the delete.
In your case, you have a return statement, and not affected rows. You can do what Morten says by doing a select
SELECT 1
and use ExecuteScalar or set up a command to handle return values from the procedure.
Imar
You must be logged in to post in the forum