Re: recordcount = -1 ??

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Mich (mich_at_nomail)
Date: 11/08/04


Date: Mon, 8 Nov 2004 17:14:23 +0100

thanks again

"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:%23bfJD2ZxEHA.3668@tk2msftngp13.phx.gbl...
> 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:
> > 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" <News@McKirahan.com> wrote in message
> > news:C7Ijd.61194$HA.25228@attbi_s01...
> >> "Mich" <mich@nomail> wrote in message
> >> news:O6iHv9WxEHA.2564@TK2MSFTNGP12.phx.gbl...
> >>> 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
> >>
> >> http://www.aspfaq.com/show.asp?id=2193
>
> --
> 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.
>
>



Relevant Pages

  • Re: Any Recordset stays empty when using SQL Native Client
    ... Even the UDL Dialogue produces parameter names with spaces, ... Additionally I eliminated the "As New" declares. ... The problem is expecting the RecordCount to always 'work'. ... You need to use a client-side cursor, or a server-side with static, keyset, ...
    (microsoft.public.vb.database.ado)
  • Re: Help with IIS server Error (Provider error 80040154 Class not registered)
    ... Mr. Barrows ... page on my ISP's web server. ... > determines whether or not the cursor supports recordcount. ...
    (microsoft.public.inetserver.asp.general)
  • Re: Please help with cmd.execute select SQL?
    ... > What is the proper format for my SQL str using command.execute? ... RecordCount requires the use of an expensive cursor. ... and connection immediately, releasing the connection back to the connection ...
    (microsoft.public.inetserver.asp.general)
  • Re: ADO Record Count Issue
    ... Your dynamic cursor allows for runtime updates so it can not determine the ... RecordCount a lot and all of those queries use adOpenStatic for the cursor ... and then the the information is pushed on to an Excel ...
    (microsoft.public.vsnet.debugging)
  • Re: recordcount = -1 ??
    ... You don't need to use Recordcount, ... cursor, ... Looping through an array is much more efficient than looping through a ... Please reply to the newsgroup. ...
    (microsoft.public.inetserver.asp.db)