MoveNext is not moving next!!
-
First, the company prefers classic asp rather than asp.net. So, apologies to the .net gurus out there. I've tried isolating various parts of this code and can't figure out why this returns the first record multiple times. Like, it's not moving to the next record in the recordset.
Dim ID2, RefDoc, RefRev, RefNotes, strSQL3
Set objCon = Server.CreateObject ("ADODB.Connection")
Set objRec = Server.CreateObject ("ADODB.Recordset")
strSQL3 = "SELECT * FROM UMIDRefDocs WHERE CardNo ='" & CardNo & "'"
objCon.Open strCon
objRec.Open strSQL3, objConIf objRec.EOF = true then
Response.Write("No reference documents exist for this card.")
End IfIf Not objRec.EOF and not objRec.BOF then
ID2 = objRec("ID")
RefDoc = objRec("RefDoc")
RefRev = objRec("RefRev")
RefNotes = objRec("RefNotes")Do Until objRec.EOF
Response.Write("<tr><td><a href='do_UMID_EditRefDocs.asp?RefDoc=" & RefDoc & "&Action=Delete&CardNo=" & CardNo & "'><img src='images/delete.gif' alt='Delete' border='0'></a>")
Response.Write("  <a href='UMID_RefDocs.asp?CardNo=" & CardNo & "&RefDoc=" & RefDoc & "&Action=Edit'><img src='images/edit.gif' alt='Edit' border='0'></a>  " & RefDoc & " </td>")
Response.Write("<td>" & RefRev & " </td>")
Response.Write("<td>" & RefNotes & " </td></tr>")objRec.MoveNext
Loop
End If
objRec.Close
objCon.Close
Set objRec = Nothing
Set objCon = NothingI've used this same pattern in other pages: Define the SQL string, open the recordset, write the table row for the current record, MoveNext, Loop, close the connection. But this time, for the given recordset I'm looking at, there are two records; I only get the first one repeated twice. Any ideas?
---------------------------------- I'm not a programmer by trade, so please don't beat me unmerciful.
-
First, the company prefers classic asp rather than asp.net. So, apologies to the .net gurus out there. I've tried isolating various parts of this code and can't figure out why this returns the first record multiple times. Like, it's not moving to the next record in the recordset.
Dim ID2, RefDoc, RefRev, RefNotes, strSQL3
Set objCon = Server.CreateObject ("ADODB.Connection")
Set objRec = Server.CreateObject ("ADODB.Recordset")
strSQL3 = "SELECT * FROM UMIDRefDocs WHERE CardNo ='" & CardNo & "'"
objCon.Open strCon
objRec.Open strSQL3, objConIf objRec.EOF = true then
Response.Write("No reference documents exist for this card.")
End IfIf Not objRec.EOF and not objRec.BOF then
ID2 = objRec("ID")
RefDoc = objRec("RefDoc")
RefRev = objRec("RefRev")
RefNotes = objRec("RefNotes")Do Until objRec.EOF
Response.Write("<tr><td><a href='do_UMID_EditRefDocs.asp?RefDoc=" & RefDoc & "&Action=Delete&CardNo=" & CardNo & "'><img src='images/delete.gif' alt='Delete' border='0'></a>")
Response.Write("  <a href='UMID_RefDocs.asp?CardNo=" & CardNo & "&RefDoc=" & RefDoc & "&Action=Edit'><img src='images/edit.gif' alt='Edit' border='0'></a>  " & RefDoc & " </td>")
Response.Write("<td>" & RefRev & " </td>")
Response.Write("<td>" & RefNotes & " </td></tr>")objRec.MoveNext
Loop
End If
objRec.Close
objCon.Close
Set objRec = Nothing
Set objCon = NothingI've used this same pattern in other pages: Define the SQL string, open the recordset, write the table row for the current record, MoveNext, Loop, close the connection. But this time, for the given recordset I'm looking at, there are two records; I only get the first one repeated twice. Any ideas?
---------------------------------- I'm not a programmer by trade, so please don't beat me unmerciful.
Bomb_shell wrote:
ID2 = objRec("ID")
RefDoc = objRec("RefDoc")
RefRev = objRec("RefRev")
RefNotes = objRec("RefNotes")These statemens are outside your loop, no wonder you see the same data over and over. :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
-
First, the company prefers classic asp rather than asp.net. So, apologies to the .net gurus out there. I've tried isolating various parts of this code and can't figure out why this returns the first record multiple times. Like, it's not moving to the next record in the recordset.
Dim ID2, RefDoc, RefRev, RefNotes, strSQL3
Set objCon = Server.CreateObject ("ADODB.Connection")
Set objRec = Server.CreateObject ("ADODB.Recordset")
strSQL3 = "SELECT * FROM UMIDRefDocs WHERE CardNo ='" & CardNo & "'"
objCon.Open strCon
objRec.Open strSQL3, objConIf objRec.EOF = true then
Response.Write("No reference documents exist for this card.")
End IfIf Not objRec.EOF and not objRec.BOF then
ID2 = objRec("ID")
RefDoc = objRec("RefDoc")
RefRev = objRec("RefRev")
RefNotes = objRec("RefNotes")Do Until objRec.EOF
Response.Write("<tr><td><a href='do_UMID_EditRefDocs.asp?RefDoc=" & RefDoc & "&Action=Delete&CardNo=" & CardNo & "'><img src='images/delete.gif' alt='Delete' border='0'></a>")
Response.Write("  <a href='UMID_RefDocs.asp?CardNo=" & CardNo & "&RefDoc=" & RefDoc & "&Action=Edit'><img src='images/edit.gif' alt='Edit' border='0'></a>  " & RefDoc & " </td>")
Response.Write("<td>" & RefRev & " </td>")
Response.Write("<td>" & RefNotes & " </td></tr>")objRec.MoveNext
Loop
End If
objRec.Close
objCon.Close
Set objRec = Nothing
Set objCon = NothingI've used this same pattern in other pages: Define the SQL string, open the recordset, write the table row for the current record, MoveNext, Loop, close the connection. But this time, for the given recordset I'm looking at, there are two records; I only get the first one repeated twice. Any ideas?
---------------------------------- I'm not a programmer by trade, so please don't beat me unmerciful.
hi Bomb_shell, As far as i know, in your problem, u assign the variable with first record and never assign it again when u loop and print out. So, as a suggestion, I re-order ur code. (I don't know much about
VB
)If objRec.EOF = true then
Response.Write("<tr><td colspan=3>No reference documents exist for this card.</td></tr>")Else
Do Until objRec.EOFID2 = objRec("ID")
RefDoc = objRec("RefDoc")
RefRev = objRec("RefRev")
RefNotes = objRec("RefNotes")Response.Write("<tr><td><a href='do\_UMID\_EditRefDocs.asp?RefDoc=" & RefDoc & "&Action=Delete&CardNo=" & CardNo & "'><img src='images/delete.gif' alt='Delete' border='0'></a>") Response.Write("  <a href='UMID\_RefDocs.asp?CardNo=" & CardNo & "&RefDoc=" & RefDoc & "&Action=Edit'><img src='images/edit.gif' alt='Edit' border='0'></a>  " & RefDoc & " </td>") Response.Write("<td>" & RefRev & " </td>") Response.Write("<td>" & RefNotes & " </td></tr>") objRec.MoveNext
Loop
End If
Hope it works!
-
First, the company prefers classic asp rather than asp.net. So, apologies to the .net gurus out there. I've tried isolating various parts of this code and can't figure out why this returns the first record multiple times. Like, it's not moving to the next record in the recordset.
Dim ID2, RefDoc, RefRev, RefNotes, strSQL3
Set objCon = Server.CreateObject ("ADODB.Connection")
Set objRec = Server.CreateObject ("ADODB.Recordset")
strSQL3 = "SELECT * FROM UMIDRefDocs WHERE CardNo ='" & CardNo & "'"
objCon.Open strCon
objRec.Open strSQL3, objConIf objRec.EOF = true then
Response.Write("No reference documents exist for this card.")
End IfIf Not objRec.EOF and not objRec.BOF then
ID2 = objRec("ID")
RefDoc = objRec("RefDoc")
RefRev = objRec("RefRev")
RefNotes = objRec("RefNotes")Do Until objRec.EOF
Response.Write("<tr><td><a href='do_UMID_EditRefDocs.asp?RefDoc=" & RefDoc & "&Action=Delete&CardNo=" & CardNo & "'><img src='images/delete.gif' alt='Delete' border='0'></a>")
Response.Write("  <a href='UMID_RefDocs.asp?CardNo=" & CardNo & "&RefDoc=" & RefDoc & "&Action=Edit'><img src='images/edit.gif' alt='Edit' border='0'></a>  " & RefDoc & " </td>")
Response.Write("<td>" & RefRev & " </td>")
Response.Write("<td>" & RefNotes & " </td></tr>")objRec.MoveNext
Loop
End If
objRec.Close
objCon.Close
Set objRec = Nothing
Set objCon = NothingI've used this same pattern in other pages: Define the SQL string, open the recordset, write the table row for the current record, MoveNext, Loop, close the connection. But this time, for the given recordset I'm looking at, there are two records; I only get the first one repeated twice. Any ideas?
---------------------------------- I'm not a programmer by trade, so please don't beat me unmerciful.
-
First, the company prefers classic asp rather than asp.net. So, apologies to the .net gurus out there. I've tried isolating various parts of this code and can't figure out why this returns the first record multiple times. Like, it's not moving to the next record in the recordset.
Dim ID2, RefDoc, RefRev, RefNotes, strSQL3
Set objCon = Server.CreateObject ("ADODB.Connection")
Set objRec = Server.CreateObject ("ADODB.Recordset")
strSQL3 = "SELECT * FROM UMIDRefDocs WHERE CardNo ='" & CardNo & "'"
objCon.Open strCon
objRec.Open strSQL3, objConIf objRec.EOF = true then
Response.Write("No reference documents exist for this card.")
End IfIf Not objRec.EOF and not objRec.BOF then
ID2 = objRec("ID")
RefDoc = objRec("RefDoc")
RefRev = objRec("RefRev")
RefNotes = objRec("RefNotes")Do Until objRec.EOF
Response.Write("<tr><td><a href='do_UMID_EditRefDocs.asp?RefDoc=" & RefDoc & "&Action=Delete&CardNo=" & CardNo & "'><img src='images/delete.gif' alt='Delete' border='0'></a>")
Response.Write("  <a href='UMID_RefDocs.asp?CardNo=" & CardNo & "&RefDoc=" & RefDoc & "&Action=Edit'><img src='images/edit.gif' alt='Edit' border='0'></a>  " & RefDoc & " </td>")
Response.Write("<td>" & RefRev & " </td>")
Response.Write("<td>" & RefNotes & " </td></tr>")objRec.MoveNext
Loop
End If
objRec.Close
objCon.Close
Set objRec = Nothing
Set objCon = NothingI've used this same pattern in other pages: Define the SQL string, open the recordset, write the table row for the current record, MoveNext, Loop, close the connection. But this time, for the given recordset I'm looking at, there are two records; I only get the first one repeated twice. Any ideas?
---------------------------------- I'm not a programmer by trade, so please don't beat me unmerciful.
-
Thanks, y'all. That was so dumb, I didn't even think of that. But it worked and I'm good now.
HaBiX wrote:
wow.. people still do plain asp/vbs?
It's a company limitation, but I'm a noob, so I don't mind learning it old school before I learn the "real" way.
---------------------------------- I'm not a programmer by trade, so please don't beat me unmerciful.