Duplicate records returned from database

Results 1 to 2 of 2

Thread: Duplicate records returned from database

  1. #1
    InDepthArts Guest

    Default Duplicate records returned from database

    Hey gurus!<BR><BR>I was wondering if you could assist me in figuring out why this page returns two instances of each record in the results. The gentleman that usually does the coding for the site is in India for three weeks and I have stared at this for about four hours... time to get some help. I have attached the section of the code I believe to be suspect. If any more information is needed please ask!<BR><BR>I thank you in advance<BR><BR>**********BEGIN CODE SNIPPET**************<BR><BR>&#039Response.write sSQL & "<BR>"<BR><BR>Set rstSimple = cnnSimple.Execute(sSQL)<BR><BR>if rstSimple.eof = false then<BR> while not rstSimple.eof<BR> rCount = rCount + 1<BR> rstSimple.MoveNext<BR> wend<BR> rstSimple.MoveFirst<BR>End If<BR><BR>&#039 Display a table of the data in the recordset. We loop through the<BR>&#039 recordset displaying the fields from the table and using MoveNext<BR>&#039 to increment to the next record. We stop when we reach EOF.<BR>%&#062; <BR> &#060;center&#062;<BR> &#060;strong&#062;&#060;font color="#000000" face="Arial, Helvetica, sans-serif" size="2"&#062;Found <BR> &#060;% = rCount %&#062; Links&#060;/font&#062;&#060;/strong&#062;<BR> &#060;/center&#062;<BR> &#060;%<BR>If CurNum + PageLength &#062; rCount Then<BR> StopCount = CurNum + PageLength - rCount<BR> &#039Response.Write StopCount & "?"<BR> pLength = PageLength - StopCount<BR> StopCount = CurNum <BR> &#039Response.Write StopCount & "!" <BR> CurNum = CurNum + pLength<BR>ElseIf CurNUm &#060;= rCount Then<BR> StopCount = CurNum <BR> CurNum = CurNum + PageLength<BR> pLength = PageLength<BR>End If<BR><BR>For i = 1 to StopCount<BR> rstSimple.MoveNext<BR>Next<BR><BR>For i = 1 to pLength<BR>&#039Response.Write i & "," & pLength & "<BR>"<BR> %&#062; <BR><BR>**************END CODE SNIPPET*************

  2. #2
    Join Date
    Dec 1969

    Default RE: Duplicate records returned from database

    (1) Nice that you put a Response.Write of the SQL there. Now what the heck does the SQL look like?<BR><BR>(2) You don&#039t show the code you use to write the stuff from the RS to the HTML output. Hard to tell, then, whether the problem is in the (invisible) SQL or the (invisible) VBScript code.<BR><BR>(3) You didn&#039t ask, but I must tell you that you are using definitely the worst of all possible ways to get a RecordCount and quite likely one of the worst to move to the proper "page" before displaying records. Go back and look at posts in this forum and the "databases" forum over the past 3 or 4 days and look for messages with "counting records" or "record count" in their subject lines.<BR><BR>(4) And even if you are using some very primitive DB and this is the only way to get the count, *at least* you should only get the count on the first "trip" to the page. That is, when the user hits you next or prior buttons, don&#039t go get the count again. Just store the count in a hidden form field on the page as a means of passing it from visible page to visible page. But, really, please don&#039t use this way to get the count!<BR><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