SqlCommands.ExecuteNonQuery always return -1
-
Hi All, I have a problem with "ExecuteNonQuery". When I insert or update my database record then SqlCommands.ExecuteNonQuery always return -1 but same thing I use another sql server its working fine. I am sure that the actual problem is in my MS-SQL Server. what should I do? Please me out......... Thanks Raj
-
Hi All, I have a problem with "ExecuteNonQuery". When I insert or update my database record then SqlCommands.ExecuteNonQuery always return -1 but same thing I use another sql server its working fine. I am sure that the actual problem is in my MS-SQL Server. what should I do? Please me out......... Thanks Raj
For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. When a trigger exists on a table being inserted or updated, the return value includes the number of rows affected by both the insert or update operation and the number of rows affected by the trigger or triggers. For all other types of statements, the return value is -1. If a rollback occurs, the return value is also -1. Anyways if you are able post here your piece of code and Sql statement then would be helpful to assist you.
Parwej Ahamad http://parwej.wordpress.com/
-
Hi All, I have a problem with "ExecuteNonQuery". When I insert or update my database record then SqlCommands.ExecuteNonQuery always return -1 but same thing I use another sql server its working fine. I am sure that the actual problem is in my MS-SQL Server. what should I do? Please me out......... Thanks Raj
-
Hi All, I have a problem with "ExecuteNonQuery". When I insert or update my database record then SqlCommands.ExecuteNonQuery always return -1 but same thing I use another sql server its working fine. I am sure that the actual problem is in my MS-SQL Server. what should I do? Please me out......... Thanks Raj
Quote From MSDN
NOCOUNT affects the return value it says "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 -1. If a rollback occurs, the return value is also -1." There is another case that causes it to return -1: if NOCOUNT is set to ON. This usually happens because the query includes the line "SET NOCOUNT ON", but it can also be set in the "Connection Defaults" screen in the SQL Server management tool.
Please go through the statement. Hope this will help you.
cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net My Latest Article : IIS Remote Debugging
-
For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. When a trigger exists on a table being inserted or updated, the return value includes the number of rows affected by both the insert or update operation and the number of rows affected by the trigger or triggers. For all other types of statements, the return value is -1. If a rollback occurs, the return value is also -1. Anyways if you are able post here your piece of code and Sql statement then would be helpful to assist you.
Parwej Ahamad http://parwej.wordpress.com/
hi, No, you could not understand what I want to say. My previous all projects were working fine all ExecuteNonQuery working well but now I don't know all are ExecuteNonQuery return -1. When I used different used another SQl Server installed in other PC. then is works fine.
-
hi, No, you could not understand what I want to say. My previous all projects were working fine all ExecuteNonQuery working well but now I don't know all are ExecuteNonQuery return -1. When I used different used another SQl Server installed in other PC. then is works fine.
Did you read the quote from my Post ?
cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net My Latest Article : IIS Remote Debugging