Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. MoveNext is not moving next!!

MoveNext is not moving next!!

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netdatabasesysadminregex
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bomb_shell
    wrote on last edited by
    #1

    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, objCon

    If objRec.EOF = true then
    Response.Write("No reference documents exist for this card.")
    End If

    If 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("&nbsp&nbsp<a href='UMID_RefDocs.asp?CardNo=" & CardNo & "&RefDoc=" & RefDoc & "&Action=Edit'><img src='images/edit.gif' alt='Edit' border='0'></a>&nbsp&nbsp" & RefDoc & "&nbsp</td>")
    Response.Write("<td>" & RefRev & "&nbsp</td>")
    Response.Write("<td>" & RefNotes & "&nbsp</td></tr>")

    objRec.MoveNext
    

    Loop

    End If
    objRec.Close
    objCon.Close
    Set objRec = Nothing
    Set objCon = Nothing

    I'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.

    L K C H 4 Replies Last reply
    0
    • B Bomb_shell

      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, objCon

      If objRec.EOF = true then
      Response.Write("No reference documents exist for this card.")
      End If

      If 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("&nbsp&nbsp<a href='UMID_RefDocs.asp?CardNo=" & CardNo & "&RefDoc=" & RefDoc & "&Action=Edit'><img src='images/edit.gif' alt='Edit' border='0'></a>&nbsp&nbsp" & RefDoc & "&nbsp</td>")
      Response.Write("<td>" & RefRev & "&nbsp</td>")
      Response.Write("<td>" & RefNotes & "&nbsp</td></tr>")

      objRec.MoveNext
      

      Loop

      End If
      objRec.Close
      objCon.Close
      Set objRec = Nothing
      Set objCon = Nothing

      I'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.

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • B Bomb_shell

        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, objCon

        If objRec.EOF = true then
        Response.Write("No reference documents exist for this card.")
        End If

        If 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("&nbsp&nbsp<a href='UMID_RefDocs.asp?CardNo=" & CardNo & "&RefDoc=" & RefDoc & "&Action=Edit'><img src='images/edit.gif' alt='Edit' border='0'></a>&nbsp&nbsp" & RefDoc & "&nbsp</td>")
        Response.Write("<td>" & RefRev & "&nbsp</td>")
        Response.Write("<td>" & RefNotes & "&nbsp</td></tr>")

        objRec.MoveNext
        

        Loop

        End If
        objRec.Close
        objCon.Close
        Set objRec = Nothing
        Set objCon = Nothing

        I'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.

        K Offline
        K Offline
        ktrrzn
        wrote on last edited by
        #3

        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.EOF

        ID2 = 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("&nbsp&nbsp<a href='UMID\_RefDocs.asp?CardNo=" & CardNo & "&RefDoc=" & RefDoc & "&Action=Edit'><img src='images/edit.gif' alt='Edit' border='0'></a>&nbsp&nbsp" & RefDoc & "&nbsp</td>")
        Response.Write("<td>" & RefRev & "&nbsp</td>")
        Response.Write("<td>" & RefNotes & "&nbsp</td></tr>")
         
        objRec.MoveNext
        

        Loop

        End If

        Hope it works!

        1 Reply Last reply
        0
        • B Bomb_shell

          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, objCon

          If objRec.EOF = true then
          Response.Write("No reference documents exist for this card.")
          End If

          If 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("&nbsp&nbsp<a href='UMID_RefDocs.asp?CardNo=" & CardNo & "&RefDoc=" & RefDoc & "&Action=Edit'><img src='images/edit.gif' alt='Edit' border='0'></a>&nbsp&nbsp" & RefDoc & "&nbsp</td>")
          Response.Write("<td>" & RefRev & "&nbsp</td>")
          Response.Write("<td>" & RefNotes & "&nbsp</td></tr>")

          objRec.MoveNext
          

          Loop

          End If
          objRec.Close
          objCon.Close
          Set objRec = Nothing
          Set objCon = Nothing

          I'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.

          C Offline
          C Offline
          C Coudou
          wrote on last edited by
          #4

          its simple. it doesn't move because it is outside the loop. it should

          Do Until objRec.EOF
          ID2 = objRec!ID
          objRec.MoveNext
          Loop

          C# コードMicrosoft End User 2000-2008 「「「「「「「「「「「「「「「「「「「「「「「「「「「「 The best things in life are free 」」」」」」」」」」」」」」」」」」」」」」」」」」」」

          1 Reply Last reply
          0
          • B Bomb_shell

            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, objCon

            If objRec.EOF = true then
            Response.Write("No reference documents exist for this card.")
            End If

            If 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("&nbsp&nbsp<a href='UMID_RefDocs.asp?CardNo=" & CardNo & "&RefDoc=" & RefDoc & "&Action=Edit'><img src='images/edit.gif' alt='Edit' border='0'></a>&nbsp&nbsp" & RefDoc & "&nbsp</td>")
            Response.Write("<td>" & RefRev & "&nbsp</td>")
            Response.Write("<td>" & RefNotes & "&nbsp</td></tr>")

            objRec.MoveNext
            

            Loop

            End If
            objRec.Close
            objCon.Close
            Set objRec = Nothing
            Set objCon = Nothing

            I'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.

            H Offline
            H Offline
            HaBiX
            wrote on last edited by
            #5

            wow.. people still do plain asp/vbs?

            B 1 Reply Last reply
            0
            • H HaBiX

              wow.. people still do plain asp/vbs?

              B Offline
              B Offline
              Bomb_shell
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups