Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Plese give me answer of this,i want to use the return value.
Posted

It doesn't. Like it says in the documentation, the return value is the number of rows affected when the command is an UPDATE, INSERT or DELETE statement (so it can be 0 or 1, not necessarily 1), and -1 for all other commands.

If you want to get the return value from a stored procedure, use an output parameter and set its type to returnvalue (see MSDN).

You may also use output parameters to retrieve any other information. Usually the most important performance parameter will be how quickly the database engine can locate the data you want to retrieve, but provided that this is quick, using output parameters instead of outputting a single row of data is a bit faster (because it eliminates the need to construct a self-describing schema that the server returns to the client application).

Why are you calling triggers directly from your application? If you can, avoid using triggers at all. And if you must, at least only use them to implement side-effects - never invoke them directly from client applications.
 
Share this answer
 
Yes, it occasionally DOES return -1 - this Codeproject article explains how to reproduce the problem and the solution
Solution: ExecuteNonQuery() always returning -1 when calling a Stored Procedure[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900