Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. SqlCommands.ExecuteNonQuery always return -1

SqlCommands.ExecuteNonQuery always return -1

Scheduled Pinned Locked Moved ASP.NET
databasesql-serversysadminhelpquestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vnsraj
    wrote on last edited by
    #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

    P B A 3 Replies Last reply
    0
    • V vnsraj

      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

      P Offline
      P Offline
      Parwej Ahamad
      wrote on last edited by
      #2

      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/

      V 1 Reply Last reply
      0
      • V vnsraj

        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

        B Offline
        B Offline
        Blue_Boy
        wrote on last edited by
        #3

        Show your code to see where could be problem.


        I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

        1 Reply Last reply
        0
        • V vnsraj

          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

          A Offline
          A Offline
          Abhijit Jana
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          • P Parwej Ahamad

            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/

            V Offline
            V Offline
            vnsraj
            wrote on last edited by
            #5

            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.

            A 1 Reply Last reply
            0
            • V vnsraj

              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.

              A Offline
              A Offline
              Abhijit Jana
              wrote on last edited by
              #6

              Did you read the quote from my Post ?

              cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net My Latest Article : IIS Remote Debugging

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups