Help with recordcount

Results 1 to 6 of 6

Thread: Help with recordcount

  1. #1
    Join Date
    Dec 1969
    Posts
    1,315

    Default Help with recordcount

    Hi,<BR><BR>I am a beginner in ASP. I couldn&#039t get the right recordcount.<BR>To check it I did as follows:<BR><BR>SQL = " Whatever ...."<BR>set rs = server.createobject("adodb.recordset")<BR>rs.open SQL, "dsn=mydsn", adopenstatic<BR>response.write "rs.recordcount is: " & rs.recordcount<BR><BR>I tried using adopenstatic, adopenforwardonly, adopenkeyset, adopendynamic. All give -1.<BR>I am using Access.<BR><BR>Thanks for any help<BR>

  2. #2
    Join Date
    Dec 1969
    Posts
    119

    Default RE: Help with recordcount

    I too faced the same situation. If recordset is empty it returns -1 and not 0.<BR><BR>Hope this clears your doubt.<BR>Arvind

  3. #3
    Join Date
    Dec 1969
    Posts
    1,315

    Default RE: Help with recordcount

    The recordset is not empty.<BR>I used this way to get the record count:<BR><BR>&#039 .... code here<BR>reccount = 0<BR>rs.MoveFirst<BR>Do While Not rs.EOF<BR>reccount = reccount + 1<BR>rs.MoveNext<BR>Loop<BR>response.write "The record count is: " & reccount<BR><BR>That gives me the right count.<BR>My question is, can I use rs.recordcount for non empty recordset with Access.<BR><BR>Thanks

  4. #4
    Join Date
    Dec 1969
    Posts
    119

    Default RE: Help with recordcount

    Well I am not sure, but u can try this<BR><BR>Give this statement <BR>rs.MoveLast<BR>Then check the record count<BR><BR><BR>


  5. #5
    Join Date
    Dec 1969
    Posts
    672

    Default RE: Help with recordcount

    try thisrs.open SQL, "dsn=mydsn", 3i too had this same problem.i wonder why this is.?
    ________
    Avandia lawsuit
    Last edited by Jay; 04-16-2011 at 01:30 AM.

  6. #6
    Join Date
    Dec 1969
    Posts
    1,315

    Default RE: Help with recordcount

    Thanks Jay, Manish, Arvind for your participation.<BR>I think I should include a constant file (adovbs.inc ??).<BR>(I am still new in ASP).<BR>I found out the values of the constants as follows:<BR>adOpenForwardOnly: 1<BR>adOpenKeyset: 2<BR>adOpenDynamic: 3<BR>adOpenStatic: 4<BR><BR>It will work if I substitute 1 or 3. But it wouldn&#039t recognize<BR>adOpenForwardOnly or adOpenDynamic (unless I include a constant file??).<BR><BR>Thanks

Posting Permissions

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