If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Duplicate output

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-22-04, 13:38
care99bare care99bare is offline
Registered User
 
Join Date: Sep 2004
Posts: 16
Question Duplicate output

I am trying to display the contents of my database, and occasionally (seemingly with no pattern) single entries in the database are displayed twice. It's almost as though the RS.MoveNext command is not executed every once in a while. This happens to the same entry each time i query the database, but the entry/entries it chooses to duplicate in the display aren't connected in any way. (I use the code to eliminate single quotes when i insert data, and i know for a fact there is only one entry in the database for the records duplicated.)

Here is my code for the display loop:

'Determine if any results were returned
If RS.BOF and RS.EOF then
response.write "<font type=arial size=2 color=yellow>There are no records associated with your search criteria"
response.write "<br />Please try again."
Else
'Display lesson info


DO WHILE NOT RS.EOF
response.write "<TABLE border='1'>"
response.write "<colgroup width = 150>"
response.write "<colgroup width = 1000>"

response.write "<TR><TD><font type=arial size=2 color=yellow>Report Number</TD>"
response.write "<TD><font type=arial size=2 color=yellow>" & RS("rnumber") & "</TD></TR>"
response.write "<TR><TD><font type=arial size=2 color=yellow>Report Title</TD>"
response.write "<TD><font type=arial size=2 color=yellow>" & RS("rtitle") & "</TD></TR>"
response.write "<TR><TD><font type=arial size=2 color=yellow>Report Date</TD>"
response.write "<TD><font type=arial size=2 color=yellow>" & RS("rdate") & "</TD></TR>"
response.write "<TR><TD><font type=arial size=2 color=yellow>Finding/Problem</TD>"
response.write "<TD><font type=arial size=2 color=yellow><a href='http://securedevako.hqda.pentagon.mil/ako/g4-usf-website/logcap/updatelesson.asp?lid=" & RS("lid") & "'</a>" & RS("finding") & "</TD></TR>"
response.write "<TR><TD><font type=arial size=2 color=yellow>Comments</TD>"
response.write "<TD><font type=arial size=2 color=yellow>" & RS("comment") & "</TD></TR>"
response.write "<TR><TD><font type=arial size=2 color=yellow>Recommendation</TD>"
response.write "<TD><font type=arial size=2 color=yellow>" & RS("recommendation") & "</TD></TR>"
response.write "<TR><TD><font type=arial size=2 color=yellow>Action Taken</TD>"
response.write "<TD><font type=arial size=2 color=yellow>" & RS("action") & "</TD></TR>"
response.write "<TR><TD><font type=arial size=2 color=yellow>Date of Action</TD>"
response.write "<TD><font type=arial size=2 color=yellow>" & RS("date") & "</TD></TR>"
response.write "<TR><TD><font type=arial size=2 color=yellow>Lead office</TD>"
response.write "<TD><font type=arial size=2 color=yellow>" & RS("lead") & "</TD></TR>"
cnumber = RS("cnumber")
ctitle = RS("ctitle")
datec = RS("cdate")
response.write "<TR><TD><font type=arial size=2 color=yellow>Correction Title</TD>"
response.write "<TD><font type=arial size=2 color=yellow><a href='" & RS("clink") & "'>" & ctitle & "</a></TD></TR>"
response.write "<TR><TD><font type=arial size=2 color=yellow>Correction Number</TD>"
response.write "<TD><font type=arial size=2 color=yellow>" & cnumber & "</TD></TR>"
response.write "<TR><TD><font type=arial size=2 color=yellow>Correction Date</TD>"
response.write "<TD><font type=arial size=2 color=yellow>" & datec & "</TD>"

response.write "</TR>"

response.write "</TABLE><br /><br />"

RS.MoveNext
LOOP
Reply With Quote
  #2 (permalink)  
Old 12-23-04, 12:27
Thrasymachus Thrasymachus is offline
SQL Server Street Fighter
 
Join Date: Nov 2004
Location: Down The Rabbit Hole
Posts: 7,979
Could it be possible you have duplicates in your database? Or maybe your query has some bad joins that are creating duplicate results?
__________________
software development is where smart people go to waste their lives
Reply With Quote
  #3 (permalink)  
Old 12-27-04, 10:07
care99bare care99bare is offline
Registered User
 
Join Date: Sep 2004
Posts: 16
I know for a fact that there is only one entry in the database for the entries that get duplicated, and as far as i know the joins are fine. This is the statement i use:

'Request the lesson info
v_query = "SELECT finding, comment, recommendation, action, date, lead, rnumber, rtitle, rdate, lid, cnumber, ctitle, cdate, clink"
v_query = v_query & " FROM lesson, report, correction"
v_query = v_query & " WHERE rnumber = rinfo and cnumber = cinfo and "
v_query = v_query & v_category & " like '%" & v_input & "%'"
v_query = v_query & " ORDER BY rinfo;"

Set RS = oConn.Execute(v_query)

That should only return each entry in the database one time. And if it were a bad join, wouldn't it return all of them twice, not just a few?

Any other ideas?
Reply With Quote
  #4 (permalink)  
Old 12-27-04, 10:31
Thrasymachus Thrasymachus is offline
SQL Server Street Fighter
 
Join Date: Nov 2004
Location: Down The Rabbit Hole
Posts: 7,979
"That should only return each entry in the database one time. And if it were a bad join, wouldn't it return all of them twice, not just a few?"

Not necessarily. If an outer join was used, you may recieve one record for a parent without a child.

It is hard to determine what is going on here from your query because your field names are not qualified with a table name, you are using the ANSI 92 join method instead of putting your join in your from clause and I have'nt the foggiest what your table structure is.
__________________
software development is where smart people go to waste their lives
Reply With Quote
  #5 (permalink)  
Old 12-27-04, 10:38
care99bare care99bare is offline
Registered User
 
Join Date: Sep 2004
Posts: 16
Thanks for your help. I know it was a little muttled, but your comment helped. I went back and took a look at the join, and figured out through trail and error that i had multiple entries in one of the tables for the primary key, which was creating multiple entries in the join table. I've been working on this for days, and i can't believe it was that simple! Thanks for all your help! I'm sure i'll have plenty more muttled questions before this thing is done!
Reply With Quote
  #6 (permalink)  
Old 12-27-04, 11:35
Thrasymachus Thrasymachus is offline
SQL Server Street Fighter
 
Join Date: Nov 2004
Location: Down The Rabbit Hole
Posts: 7,979
not a problem. I am here through Thursday evening and I stayed logged into DB Forums to break up the average day of a code monkey.
__________________
software development is where smart people go to waste their lives
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On