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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. getting RecordCount = -1

getting RecordCount = -1

Scheduled Pinned Locked Moved Database
sharepointsysadminhelp
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.
  • A Offline
    A Offline
    Ankur Bakliwal
    wrote on last edited by
    #1

    Hello Friends, I have a problem with recordsets. I m getting Rs.RecordCount = -1 while calling a store procedures here is code - Set cmd = Server.CreateObject("ADODB.Command") Set rs = Server.CreateObject("ADODB.RecordSet") cmd.ActiveConnection = myCon cmd.CommandText = "SP_Name" cmd.CommandType = 4 cmd.CommandTimeout = 300 cmd.Parameters.Append cmd.CreateParameter("@par1",20,1,10,1) cmd.Parameters.Append cmd.CreateParameter("@par2",20,1,10,1) cmd.Parameters.Append cmd.CreateParameter("@par3",20,1,10,20) cmd.Parameters.Append cmd.CreateParameter("@par4",20,1,10,Null) Rs.CursorLocation = 3 Rs.LockType = 1 Rs.CursorType = 3 Set Rs = cmd.Execute Response.Write "
    RecordCount = " & Rs.RecordCount pls give some usefull solution. Thanks, Ankur Bakliwal

    C R 2 Replies Last reply
    0
    • A Ankur Bakliwal

      Hello Friends, I have a problem with recordsets. I m getting Rs.RecordCount = -1 while calling a store procedures here is code - Set cmd = Server.CreateObject("ADODB.Command") Set rs = Server.CreateObject("ADODB.RecordSet") cmd.ActiveConnection = myCon cmd.CommandText = "SP_Name" cmd.CommandType = 4 cmd.CommandTimeout = 300 cmd.Parameters.Append cmd.CreateParameter("@par1",20,1,10,1) cmd.Parameters.Append cmd.CreateParameter("@par2",20,1,10,1) cmd.Parameters.Append cmd.CreateParameter("@par3",20,1,10,20) cmd.Parameters.Append cmd.CreateParameter("@par4",20,1,10,Null) Rs.CursorLocation = 3 Rs.LockType = 1 Rs.CursorType = 3 Set Rs = cmd.Execute Response.Write "
      RecordCount = " & Rs.RecordCount pls give some usefull solution. Thanks, Ankur Bakliwal

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      What happens if you take those parameters, and call the stored proc within SQL Server ?

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      A 1 Reply Last reply
      0
      • C Christian Graus

        What happens if you take those parameters, and call the stored proc within SQL Server ?

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        A Offline
        A Offline
        Ankur Bakliwal
        wrote on last edited by
        #3

        In Sql Server with same parameter that SP gives me 2 records as result.

        Thanks, Ankur Bakliwal

        C 1 Reply Last reply
        0
        • A Ankur Bakliwal

          In Sql Server with same parameter that SP gives me 2 records as result.

          Thanks, Ankur Bakliwal

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Then there must be a problem with the code. Not sure what, without seeing the proc.

          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

          1 Reply Last reply
          0
          • A Ankur Bakliwal

            Hello Friends, I have a problem with recordsets. I m getting Rs.RecordCount = -1 while calling a store procedures here is code - Set cmd = Server.CreateObject("ADODB.Command") Set rs = Server.CreateObject("ADODB.RecordSet") cmd.ActiveConnection = myCon cmd.CommandText = "SP_Name" cmd.CommandType = 4 cmd.CommandTimeout = 300 cmd.Parameters.Append cmd.CreateParameter("@par1",20,1,10,1) cmd.Parameters.Append cmd.CreateParameter("@par2",20,1,10,1) cmd.Parameters.Append cmd.CreateParameter("@par3",20,1,10,20) cmd.Parameters.Append cmd.CreateParameter("@par4",20,1,10,Null) Rs.CursorLocation = 3 Rs.LockType = 1 Rs.CursorType = 3 Set Rs = cmd.Execute Response.Write "
            RecordCount = " & Rs.RecordCount pls give some usefull solution. Thanks, Ankur Bakliwal

            R Offline
            R Offline
            roel_v
            wrote on last edited by
            #5

            I found this on MSDN: The cursor type of the Recordset object affects whether the number of records can be determined. The RecordCount property will return -1 for a forward-only cursor; the actual count for a static or keyset cursor; and either -1 or the actual count for a dynamic cursor, depending on the data source. You are using CursorType = 3, which corresponds to a static cursor, so it should return. However, it also says: The property returns -1 when ADO cannot determine the number of records or if the provider or cursor type does not support RecordCount. What provider are you using? In general, the safest solution is to just include a count(*) in your stored procedure and return that as an output parameter. Let me know if this works for you. Roel

            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