Professional Web Applications Themes

recordcount = -1 ?? - ASP Database

Hi, I defined a query (name = myquery) in Access like this: SELECT IIf([wwk]='Maandag',[maandag],IIf([wwk]='Dinsdag',[dinsdag],IIf([wwk]='Woens dag',[woensdag],IIf([wwk]='Donderdag',[donderdag],[vrijdag])))) FROM daguur; When executing in Access and filling e.g. 'maandag' as parameter, it works (10 records). No problem. In ASP: set OBJDC = Server.CreateObject("ADODB.Connection") objdc.Open("provider=Microsoft.Jet.OLEDB.4.0; Data Source =c:\mydb.mdb") set rs=Server.createObject("ADODB.recordset") objdc.myquery wwk,rs rec=rs.recordcount My problem is: no error, but rec = -1. Any idea why i don't get the 10 records? Thanks Mich...

  1. #1

    Default recordcount = -1 ??

    Hi,

    I defined a query (name = myquery) in Access like this:
    SELECT
    IIf([wwk]='Maandag',[maandag],IIf([wwk]='Dinsdag',[dinsdag],IIf([wwk]='Woens
    dag',[woensdag],IIf([wwk]='Donderdag',[donderdag],[vrijdag]))))
    FROM daguur;
    When executing in Access and filling e.g. 'maandag' as parameter, it works
    (10 records). No problem.

    In ASP:
    set OBJDC = Server.CreateObject("ADODB.Connection")
    objdc.Open("provider=Microsoft.Jet.OLEDB.4.0; Data Source =c:\mydb.mdb")
    set rs=Server.createObject("ADODB.recordset")
    objdc.myquery wwk,rs
    rec=rs.recordcount

    My problem is: no error, but rec = -1.
    Any idea why i don't get the 10 records?
    Thanks
    Mich


    Mich Guest

  2. #2

    Default Re: recordcount = -1 ??

    "Mich" <michnomail> wrote in message
    news:phx.gbl... 
    IIf([wwk]='Maandag',[maandag],IIf([wwk]='Dinsdag',[dinsdag],IIf([wwk]='Woens 

    http://www.aspfaq.com/show.asp?id=2193


    McKirahan Guest

  3. #3

    Default Re: recordcount = -1 ??

    Thanks, but i need to run that query from Access (with parameter wwk). Is
    there no parameter i can use to change the cursor in order to get the
    recordcount (and also to get rs.fields("maandag").value)?


    "McKirahan" <com> wrote in message
    news:C7Ijd.61194$.. 
    >[/ref]
    IIf([wwk]='Maandag',[maandag],IIf([wwk]='Dinsdag',[dinsdag],IIf([wwk]='Woens [/ref]
    works 
    >
    > http://www.aspfaq.com/show.asp?id=2193
    >
    >[/ref]


    Mich Guest

  4. #4

    Default Re: recordcount = -1 ??

    It's explained in the article. You don't need to use Recordcount, but if you
    insist on using it for some reason, you need to use either a client-side
    cursor, or a server-side non-forward-only cursor. I would go with a static
    server-side cursor (although a keyset or dynamic cursor would also work).

    set rs=Server.createObject("ADODB.recordset")
    rs.CursorType=3 '3=adOpenStatic
    objdc.myquery wwk,rs
    rec=rs.recordcount

    HOWEVER, this is inefficient. You should take the advice given in the
    article and use a GetRows array to get your record count. Like this:

    dim arData
    set rs=Server.createObject("ADODB.recordset")
    objdc.myquery wwk,rs
    if not rs.eof then arData = rs.GetRows
    rs.close: set rs = nothing
    objdc.close: set objdc=nothing
    if isArray(arData) then
    rec = Ubound(arData,2) + 1
    else
    rec = 0
    end if

    Looping through an array is much more efficient than looping through a
    recordset. See:
    http://www.aspfaq.com/show.asp?id=2467

    HTH,
    Bob Barrows

    Mich wrote: 
    >>[/ref]
    >[/ref]
    IIf([wwk]='Maandag',[maandag],IIf([wwk]='Dinsdag',[dinsdag],IIf([wwk]='Woens 
    >>
    >> http://www.aspfaq.com/show.asp?id=2193[/ref][/ref]

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Guest

  5. #5

    Default Re: recordcount = -1 ??

    thanks again

    "Bob Barrows [MVP]" <SPAMcom> wrote in message
    news:%phx.gbl... 
    you 
    > >[/ref]
    >[/ref]
    IIf([wwk]='Maandag',[maandag],IIf([wwk]='Dinsdag',[dinsdag],IIf([wwk]='Woens [/ref]
    >
    > --
    > Microsoft MVP -- ASP/ASP.NET
    > Please reply to the newsgroup. The email account listed in my From
    > header is my spam trap, so I don't check it very often. You will get a
    > quicker response by posting to the newsgroup.
    >
    >[/ref]


    Mich Guest

Similar Threads

  1. something like recordcount?
    By phil in forum ASP.NET Data Grid Control
    Replies: 3
    Last Post: May 9th, 09:05 AM
  2. RecordCount
    By Mark in forum ASP
    Replies: 5
    Last Post: October 31st, 04:49 AM
  3. Getting a recordcount
    By Andy Levy in forum PHP Development
    Replies: 3
    Last Post: October 29th, 08:55 AM
  4. recordcount -1
    By middletree in forum ASP
    Replies: 8
    Last Post: October 16th, 02:06 PM
  5. RecordCount Property and SQL
    By Scott in forum ASP Database
    Replies: 2
    Last Post: July 22nd, 01:17 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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