ExecuteNonQuery always returns -1

executenonquery returns -1 on success

ExecuteNonQuery is suppose to return the number of rows inserted, updated or deleted but in my case it always return -1 even though the record is successfully added.

Found out

SET NOCOUNT OFF

was missing my in my stored procedure. If you have multiple SQL statements in your stored procedure, initially set it to on by

SET NOCOUNT ON

which will not count any rows affected. Later to monitor the statement you are actually interested in, set it to OFF.

Hope that resolves your problem!