Counting records problems

Results 1 to 4 of 4

Thread: Counting records problems

  1. #1
    Rodger Guest

    Default Counting records problems

    I took the advice I read recently in one of your articles re. using COUNT() in SQL rather than counting recordsets, but am having great trouble getting my ASP code to read the results. This is my SQL:<BR><BR> mySQL4="SELECT COUNT(pma.property_id) AS Total "<BR> mySQL4 = mySQL4 & " FROM g_address a, g_property_mailing_address pma, g_data_reference dr"<BR> mySQL4 = mySQL4 & " WHERE a.address_id = pma.mail_id "<BR> mySQL4 = mySQL4 & " AND display_address LIKE &#039"<BR> mySQL4 = mySQL4 & strAddressin & "%&#039"<BR> mySQL4 = mySQL4 & " AND pma.property_id = dr.module_id "<BR><BR>The output is entered into the asp here:<BR><BR> AddressCount = rstemp4("Total")<BR><BR>Trouble begins at the point I try to use AddressCount to write HTML :<BR><BR>For j=0 To AddressCount - 1<BR> response.write"&#060;TR&#062;&#060;td&#062;Item Number: " & j & "&#060;/td&#062;&#060;td&#062;" & rstemp("property_id") & "&#060;/td&#062;&#060;/tr&#062;"<BR>Next<BR><BR>There should be more than 1 property_id<BR><BR>I&#039ve been working on this for a day now, any ideas?

  2. #2
    Rodger Guest

    Default RE: Counting records problems

    Should have added that from that last For statement I&#039d get an error saying "type mismatch" which I don&#039t understand &#039cos the number 9 should have been in AddressCount, and I thought VBScript only has 1 datatype

  3. #3
    Kyle Wilson Guest

    Default RE: Counting records problems

    Two things, though I use SQL it&#039s not my strong suit so bear with me. I believe Count is an internal function and that giving it a columname creates a new variable Count...<BR><BR>If that&#039s true I don&#039t think the id is what you should be referencing any longer but rather Count? I could be wrong.<BR><BR>As for the type mismatch you might try a Int(FormatNumber(varname)) I seem to get that error alot and that usually solves it.<BR><BR>Good Luck,

  4. #4
    Join Date
    Dec 1969

    Default RE: Counting records problems

    A quick glance makes me think the syntax looks ok. The error occurs on the for line, correct? If so, maybe you could try spitting it out to response.write just to see what the value of the record count *is*. One thing I noticed is that you aren&#039t calling movenext, but that might just be me trying to read too much into your code.

Posting Permissions

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