ASP looping question

Discussion in 'ASP General' started by JP SIngh, Jul 5, 2004.

  1. JP SIngh

    JP SIngh Guest

    I have the following code using which I am writing to a text file.

    The select statement returns 3 records and I can see that from the
    response.write statement but when it writes to the file it only writes the
    top 2 records. It is missing the last record.

    The output on the screen is

    mac address = 0050.14a2.139e vlan = Vlan202
    mac address = 0050.14a2.13ff vlan = Vlan250
    mac address = 0010.a41b.036c vlan = Vlan250

    but the output in the text file is (you can see the last record in the
    recordset is missing.)

    address 0050.14a2.139e vlan-name Vlan202
    address 0050.14a2.13ff vlan-name Vlan250

    Does anyone know why?


    SQL = "Select macaddress, vlan FROM macmap where status = 'Live' or status =
    'Approved' ORDER BY id"
    SET RS = conn.Execute(SQL)
    Do Until NOT RS.EOF
    straddress = rs("macaddress")
    strvlan = rs("vlan")
    response.write " mac address = " & straddress & " vlan = " & strVlan &
    "<br>"
    TSO.write "address " & straddress & " vlan-name " & strvlan & vbcrlf
    RS.MoveNext
    Loop
    RS.Close
    Set RS = NOTHING
    conn.close
    set conn = nothing
     
    JP SIngh, Jul 5, 2004
    #1
    1. Advertising

  2. JP SIngh

    JP SIngh Guest

    Just a quick follow up I have noticed that it does not matter how many
    records it returns it always writes only 2 records out to the file.

    "JP SIngh" <> wrote in message
    news:%...
    > I have the following code using which I am writing to a text file.
    >
    > The select statement returns 3 records and I can see that from the
    > response.write statement but when it writes to the file it only writes the
    > top 2 records. It is missing the last record.
    >
    > The output on the screen is
    >
    > mac address = 0050.14a2.139e vlan = Vlan202
    > mac address = 0050.14a2.13ff vlan = Vlan250
    > mac address = 0010.a41b.036c vlan = Vlan250
    >
    > but the output in the text file is (you can see the last record in the
    > recordset is missing.)
    >
    > address 0050.14a2.139e vlan-name Vlan202
    > address 0050.14a2.13ff vlan-name Vlan250
    >
    > Does anyone know why?
    >
    >
    > SQL = "Select macaddress, vlan FROM macmap where status = 'Live' or status

    =
    > 'Approved' ORDER BY id"
    > SET RS = conn.Execute(SQL)
    > Do Until NOT RS.EOF
    > straddress = rs("macaddress")
    > strvlan = rs("vlan")
    > response.write " mac address = " & straddress & " vlan = " & strVlan &
    > "<br>"
    > TSO.write "address " & straddress & " vlan-name " & strvlan & vbcrlf
    > RS.MoveNext
    > Loop
    > RS.Close
    > Set RS = NOTHING
    > conn.close
    > set conn = nothing
    >
    >
     
    JP SIngh, Jul 5, 2004
    #2
    1. Advertising

  3. JP SIngh

    JP SIngh Guest

    My applogies everyone that was a daft question ;)

    I was writing to a different file and viewing a totally different one

    sorry


    "JP SIngh" <> wrote in message
    news:%...
    > Just a quick follow up I have noticed that it does not matter how many
    > records it returns it always writes only 2 records out to the file.
    >
    > "JP SIngh" <> wrote in message
    > news:%...
    > > I have the following code using which I am writing to a text file.
    > >
    > > The select statement returns 3 records and I can see that from the
    > > response.write statement but when it writes to the file it only writes

    the
    > > top 2 records. It is missing the last record.
    > >
    > > The output on the screen is
    > >
    > > mac address = 0050.14a2.139e vlan = Vlan202
    > > mac address = 0050.14a2.13ff vlan = Vlan250
    > > mac address = 0010.a41b.036c vlan = Vlan250
    > >
    > > but the output in the text file is (you can see the last record in the
    > > recordset is missing.)
    > >
    > > address 0050.14a2.139e vlan-name Vlan202
    > > address 0050.14a2.13ff vlan-name Vlan250
    > >
    > > Does anyone know why?
    > >
    > >
    > > SQL = "Select macaddress, vlan FROM macmap where status = 'Live' or

    status
    > =
    > > 'Approved' ORDER BY id"
    > > SET RS = conn.Execute(SQL)
    > > Do Until NOT RS.EOF
    > > straddress = rs("macaddress")
    > > strvlan = rs("vlan")
    > > response.write " mac address = " & straddress & " vlan = " & strVlan

    &
    > > "<br>"
    > > TSO.write "address " & straddress & " vlan-name " & strvlan & vbcrlf
    > > RS.MoveNext
    > > Loop
    > > RS.Close
    > > Set RS = NOTHING
    > > conn.close
    > > set conn = nothing
    > >
    > >

    >
    >
     
    JP SIngh, Jul 5, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Doug
    Replies:
    10
    Views:
    7,426
    teeg01
    Dec 5, 2008
  2. Pekka Niiranen
    Replies:
    5
    Views:
    344
    Pekka Niiranen
    Oct 31, 2004
  3. manstey

    looping question 4 NEWB

    manstey, Jul 6, 2006, in forum: Python
    Replies:
    8
    Views:
    301
    manstey
    Jul 9, 2006
  4. Replies:
    6
    Views:
    274
    Tim Chase
    Oct 3, 2006
  5. Replies:
    5
    Views:
    289
Loading...

Share This Page