recordset.recordcount return allways -1 on select statements

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default recordset.recordcount return allways -1 on select statements

    Greetings

    On my ASP application I want to retrieve the number
    (Recordset.recordCount property) of records affected by a select
    statement, but I keep getting -1. Even with an example of W3Schools
    (avaiable at [url]http://www.w3schools.com/ado/prop_rs_recordcount.asp[/url]) I get
    -1 and not the records affected.
    Here is some code (from the w3's example).

    <%
    set conn=Server.CreateObject("ADODB.Connection")
    conn.Provider="Microsoft.Jet.OLEDB.4.0"
    conn.Open(Server.Mappath("northwind.mdb"))
    set rs=Server.CreateObject("ADODB.recordset")
    sql="SELECT * FROM Customers"
    rs.Open sql,conn

    if rs.Supports(adApproxPosition)=true then
    i=rs.RecordCount
    response.write("The number of records is: " & i)
    end if
    rs.Close
    conn.Close
    %>

    What seems to be the problem?
    Thanks in advance.

    Sérgio

    Sérgio Almeida Guest

  2. Similar Questions and Discussions

    1. CFIF return RecordCount EQ 0
      Hi - need to check if there is a record in a MySQL database. If there is display it if there not show a default Address. Here's what I have. It...
    2. Best way for implementing mutliple select statements
      What's the most efficient method for using multiple select statements from different tables? Open db connection once or open connection for each...
    3. Newbie: batch statements and return codes.
      Hi all, I'm trying to work out how I am going to develope some procs and functions within DB2. Usually what I do when playing with code and testing...
    4. Need a little help on RecordCount recordset function
      I am testing a basic function to access a db from the web and step through a set of client email addresses and send each one an email. I have a...
    5. Using IF and IsNull statements in SELECT
      You would do something like this... select CustomerLastName + isnull(', '+CustomerFirstName,'') from tb -- -oj RAC v2.2 & QALite!...
  3. #2

    Default Re: recordset.recordcount return allways -1 on select statements

    popular question. Your cursor is wrong. Search google - that question is
    everywhere

    "Sérgio Almeida" <sgalmeidaNOSPAM@bragatelNOSPAM.pt> wrote in message
    news:OgpRtOnmDHA.2772@TK2MSFTNGP10.phx.gbl...
    > Greetings
    >
    > On my ASP application I want to retrieve the number
    > (Recordset.recordCount property) of records affected by a select
    > statement, but I keep getting -1. Even with an example of W3Schools
    > (avaiable at [url]http://www.w3schools.com/ado/prop_rs_recordcount.asp[/url]) I get
    > -1 and not the records affected.
    > Here is some code (from the w3's example).
    >
    > <%
    > set conn=Server.CreateObject("ADODB.Connection")
    > conn.Provider="Microsoft.Jet.OLEDB.4.0"
    > conn.Open(Server.Mappath("northwind.mdb"))
    > set rs=Server.CreateObject("ADODB.recordset")
    > sql="SELECT * FROM Customers"
    > rs.Open sql,conn
    >
    > if rs.Supports(adApproxPosition)=true then
    > i=rs.RecordCount
    > response.write("The number of records is: " & i)
    > end if
    > rs.Close
    > conn.Close
    > %>
    >
    > What seems to be the problem?
    > Thanks in advance.
    >
    > Sérgio
    >

    Jeff Clark Guest

  4. #3

    Default Re: recordset.recordcount return allways -1 on select statements

    > (Recordset.recordCount property) of records affected by a select
    > statement, but I keep getting -1.
    [url]http://www.aspfaq.com/2193[/url]


    Aaron Bertrand [MVP] Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139