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. Database & SysAdmin
  3. Database
  4. can't get "# of rows affected" when executing a tored procedure

can't get "# of rows affected" when executing a tored procedure

Scheduled Pinned Locked Moved Database
databasetutorialquestionannouncement
5 Posts 3 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.
  • M Offline
    M Offline
    Mohammad A Gdeisat
    wrote on last edited by
    #1

    Hi I've an UPDATE statement inside a stored procedure, when I execute the SqlCommand.ExecuteNonQuery() function I get a return value of -1, but I need to get the # of rows affected by the update statement. Any Idea how to do this? Thanks

    And ever has it been that love knows not its own depth until the hour of separation Mohammad Gdeisat

    W M 2 Replies Last reply
    0
    • M Mohammad A Gdeisat

      Hi I've an UPDATE statement inside a stored procedure, when I execute the SqlCommand.ExecuteNonQuery() function I get a return value of -1, but I need to get the # of rows affected by the update statement. Any Idea how to do this? Thanks

      And ever has it been that love knows not its own depth until the hour of separation Mohammad Gdeisat

      W Offline
      W Offline
      Wendelius
      wrote on last edited by
      #2

      Add an OUT parameter to your stored procedure and using it, return the number of affected rows. To resolve it inside the procedure use @@ROWCOUNT.

      The need to optimize rises from a bad design.My articles[^]

      M 1 Reply Last reply
      0
      • M Mohammad A Gdeisat

        Hi I've an UPDATE statement inside a stored procedure, when I execute the SqlCommand.ExecuteNonQuery() function I get a return value of -1, but I need to get the # of rows affected by the update statement. Any Idea how to do this? Thanks

        And ever has it been that love knows not its own depth until the hour of separation Mohammad Gdeisat

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #3

        declare a variable and, after the update, set @Var = @@Rowcount Select @Var Records

        Never underestimate the power of human stupidity RAH

        M 1 Reply Last reply
        0
        • M Mycroft Holmes

          declare a variable and, after the update, set @Var = @@Rowcount Select @Var Records

          Never underestimate the power of human stupidity RAH

          M Offline
          M Offline
          Mohammad A Gdeisat
          wrote on last edited by
          #4

          Thanks alot, it worked! :)

          And ever has it been that love knows not its own depth until the hour of separation Mohammad Gdeisat

          1 Reply Last reply
          0
          • W Wendelius

            Add an OUT parameter to your stored procedure and using it, return the number of affected rows. To resolve it inside the procedure use @@ROWCOUNT.

            The need to optimize rises from a bad design.My articles[^]

            M Offline
            M Offline
            Mohammad A Gdeisat
            wrote on last edited by
            #5

            Thanks alot, it worked! :-)

            And ever has it been that love knows not its own depth until the hour of separation Mohammad Gdeisat

            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