Consequently, what is the return value of ExecuteNonQuery? Although ExecuteNonQuery does not return any rows, output parameters or return values that are 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. For all other types of statements, the return value is It is used to execute the sql statements like update, insert, delete etc.
ExecuteNonQuery executes the command and returns the number of rows affected. If the Result Set contains more than one columns or rows , it will take only the value of first column of the first row, and all other values will ignore. ExecuteReader expects to run a query command or a stored procedure that selects records. Its return type is DataReader and a DataReader object must always be declared in order to hold the result returned by the query. Disclaimer : The code samples and API available at www.
You are free to use it for commercial as well as non-commercial use at your own risk, but you cannot use it for posting on blogs or other tutorial websites similar to www. All the code samples and API provided by the authors are solely their creation and neither the author nor the site are responsible if it does not work as intended.
I agree to the above terms. Related Article. NET Version History. How to create a calculator in ASP. NET using Session. Microsoft makes no warranties, express or implied, with respect to the information provided here. Executes a Transact-SQL statement against the connection and returns the number of rows affected.
For more information about streaming, see SqlClient Streaming Support. An exception occurred while executing the command against a locked row.
This exception is not generated when you are using Microsoft. NET Framework version 1. How can you find out? You'll have to debug it. You can use Sql Profiler to see the exact sql that was sent and then figure it out from there. I already debugged. It is showing values also. Then you have to figure out why it is not in db.
As I said, run sql profiler and see the exact sql that is being run. I'm not sure what you want us to do. We can't see what you are doing so there is no way for us to know what you have done wrong. Maciej Los Oct am. You probably does not have permission to change data Richard MacCutchan Oct am. If you want help, the please show us your code, and the values of all the variables that you are trying to insert. Top Rated Most Recent. Accept Solution Reject Solution. You will only get a value other than -1 for a delete, update or insert statement that commits a value.
If a rollback occurs, you'll get -1 so it could well be that the database is rolling back the value. As you haven't even supplied the most minimum of information, I'm going to guess it's something like a rollback that's causing you not to see any data.
I will revise my opinion once we actually see some code. Posted Oct am Pete O'Hanlon.
0コメント