Results 1 to 4 of 4

Thread: Record Set .RecordCount

  1. #1

    Thread Starter
    Hyperactive Member dogfish227's Avatar
    Join Date
    Oct 2002
    Location
    GA
    Posts
    409

    Record Set .RecordCount

    set rs=Server.CreateObject("ADODB.recordset")
    sql="SELECT * FROM pics"
    rs.Open sql,objConn
    response.write(rs.Fields("picture").Value)
    i=rs.RecordCount
    response.write("The number of records is: " & i)
    rs.Close

    what is wrong with the code above im am useing to get the number of records.

    i want it to write 1 b/c there is one record in the table.

    the SQL is defiantly right b/c response.write(rs.Fields("picture").Value) write out the value of the one thng in the database

    but RecordCount is giveing me -1 why is this???

  2. #2
    Member
    Join Date
    Mar 2005
    Posts
    56

    Re: Record Set .RecordCount

    What cursor style are you using? RecordCount only works with certian cursor styles, would be better off to use count() to get the record count.

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Record Set .RecordCount

    When you dont pass the lock type and cursor type parameters the defualt is a forward only readonly recordset that
    does not support the .Recordcount property.

    Try using
    rs.Open sql,objConn, adOpenKeyset, adLockOptimistic, adCmdText
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4
    New Member
    Join Date
    Mar 2005
    Posts
    9

    Re: Record Set .RecordCount

    hi deae

    fs
    fsd
    f
    dsf
    sd
    sd
    s
    f
    sf
    sa
    fsdsdfsafsfaf

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width