record count

Results 1 to 5 of 5

Thread: record count

  1. #1
    mnar Guest

    Default record count

    i am trying to count the no of recs in the recordset. when i tried to use record count, absolute position, move last methods -i get an error saying that the object doesnt support it. <BR>know what mistake i am making or solution to make it work? <BR><BR>here is the code:<BR><BR>&#060;%@ Language=VBScript %&#062;<BR>&#060;%dim conn, rsdept, query<BR>set conn= server.CreateObject("ADODB.Connection")<BR>conn.Op en "mnaru"<BR>query = "select * from ciempdir order by ID"<BR>set rsdept = server.CreateObject("ADODB.Recordset")<BR>rsdept.O pen query,conn,adOpenDynamic<BR><BR>dim i<BR>for i = 1 to rsdept.eof step 1<BR>next <BR>Response.Write i<BR><BR>%&#062;

  2. #2
    Join Date
    Dec 1969

    Default RE: record count

    Try using this:<BR><BR>do while not rsdept.eof=true<BR>Response.write(rsdept("col1"))< BR>..<BR>..<BR>rsdept.movenext<BR>loop<BR><BR>

  3. #3
    MG Guest

    Default RE: record count

    dim conn, rsdept, query, cnt<BR>set conn= server.CreateObject("ADODB.Connection")<BR>conn.Op en "mnaru"<BR>query = "select count(ID) as cnt from ciempdir"<BR>set rsdept = server.CreateObject("ADODB.Recordset")<BR>rsdept.O pen query,conn,adOpenDynamic<BR>cnt = rsdept("cnt")<BR>rsdept.close<BR>set rsdept = nothing<BR>conn.close<BR>set conn = nothing<BR><BR>Response.Write cnt<BR><BR>

  4. #4
    MG Guest

    Default Not a good method

    There are many other ways to count records without looping through the entire table.

  5. #5
    Jury Guest

    Default RE: record count

    I think this is the best way counting your records without looping.<BR><BR> StrQuery = "Select * From Tabel;"<BR> StrQuery, StrConn,1,3 &#039Without the 1,3 you get a <BR>-1 as result<BR> Tel= ObjRS.recordcount &#039Must use before execute query<BR><BR> Response.write "Er zijn " & Tel & "records aanwezig"<BR><BR>Have fun coding<BR>Jury<BR>

Posting Permissions

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