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. General Programming
  3. Visual Basic
  4. number of affected rows

number of affected rows

Scheduled Pinned Locked Moved Visual Basic
databasesql-serversysadminquestion
6 Posts 2 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.
  • E Offline
    E Offline
    ecentinela
    wrote on last edited by
    #1

    When I make a query in sql server 2005 like "SELECT something FROM somewhere", there is a way to know the number of selected rows without the need of other query "SELECT COUNT(*) FROM somewhere" ? Thanks

    D 1 Reply Last reply
    0
    • E ecentinela

      When I make a query in sql server 2005 like "SELECT something FROM somewhere", there is a way to know the number of selected rows without the need of other query "SELECT COUNT(*) FROM somewhere" ? Thanks

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      This is returned automatically unless the SELECT statement is preceded by a SELECT NOCOUNT ON statement. This is not applicable to Access databases though. Jet doesn't support returning the "number of rows affected". What is it your're trying to do. So far, this question has nothing to do with VB.NET... RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      E 1 Reply Last reply
      0
      • D Dave Kreskowiak

        This is returned automatically unless the SELECT statement is preceded by a SELECT NOCOUNT ON statement. This is not applicable to Access databases though. Jet doesn't support returning the "number of rows affected". What is it your're trying to do. So far, this question has nothing to do with VB.NET... RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        E Offline
        E Offline
        ecentinela
        wrote on last edited by
        #3

        I want to redim an array to the number of rows selected, and fill this array from one of the columns of the query.

        D 1 Reply Last reply
        0
        • E ecentinela

          I want to redim an array to the number of rows selected, and fill this array from one of the columns of the query.

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Then you're looking in the wrong place. Fill your DataSet, DataTable, or whatver your using to store the results of the query. Then use the count of the number of Rows in the collection to set your array dimensions.

          Dim ds As DataSet
          ' code to fill DataSet with a couple of tables...
          Dim arraySize As Integer
          arraySize = ds.Tables("whatever").Rows.Count
          Dim myArray(arraySize) As String
          .
          .
          .

          RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

          E 1 Reply Last reply
          0
          • D Dave Kreskowiak

            Then you're looking in the wrong place. Fill your DataSet, DataTable, or whatver your using to store the results of the query. Then use the count of the number of Rows in the collection to set your array dimensions.

            Dim ds As DataSet
            ' code to fill DataSet with a couple of tables...
            Dim arraySize As Integer
            arraySize = ds.Tables("whatever").Rows.Count
            Dim myArray(arraySize) As String
            .
            .
            .

            RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

            E Offline
            E Offline
            ecentinela
            wrote on last edited by
            #5

            Yes, you are right. I was working with a not too good method. With a dataset it's better implemented. Thanks a lot.

            D 1 Reply Last reply
            0
            • E ecentinela

              Yes, you are right. I was working with a not too good method. With a dataset it's better implemented. Thanks a lot.

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              No problem! :-D RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

              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