p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

proasp_codeclinic thread: Help! - Repeat Function or Loop??


Message #1 by info@e... on Fri, 6 Jul 2001 21:33:56
Hello Elmer,

Try changing the following line from
TechNotes = LCase(rsTechNotes("Detail"))
to
set TechNotes = rsTechNotes("Detail")

The first sets technotes to the value in the recordset which explains the
results you got. The second version sets technotes to the Field object so
you're movenext affects the value.

John

> -----Original Message-----
> Subject: Help! - Repeat Function or Loop??
> From: info@e...
> Date: Fri, 6 Jul 2001 21:33:56
> X-Message-Number: 3
>
> Hello everyone,
>
> I need help! I am having trouble repeating a field with a replace
> function. I have a table in SQL called TechNotes, here we
> have multiples
> rows of detail for each record ordered by LineNumber. I want
> to be able to
> display all the fields for each record but I also want to use
> a Replace
> function on the detail to replace "-" with a "<li>". I put a variable
> called Technotes so that it would be easier for me to add the replace
> function but it now repeats the same row (#1) over & over.
> What should I
> do? Is looping better? If so, how do I do it? Thanks!
>
> Regards,
> Elmer M.
>
>
> <---CODE BEGINS HERE--->
>
> <%@LANGUAGE="VBSCRIPT"%>
> <!--#include file="../Connections/conn.asp" -->
> <%
> set rsTechNotes = Server.CreateObject("ADODB.Recordset")
> rsTechNotes.ActiveConnection = MM_conn_STRING
> rsTechNotes.Source = "SELECT *  FROM TechNotes  WHERE SKU = '052825'
> ORDER BY LineNumber"
> rsTechNotes.CursorType = 0
> rsTechNotes.CursorLocation = 2
> rsTechNotes.LockType = 3
> rsTechNotes.Open()
> rsTechNotes_numRows = 0
> %>
> <%
> Dim Repeat1__numRows
> Repeat1__numRows = -1
> Dim Repeat1__index
> Repeat1__index = 0
> rsTechNotes_numRows = rsTechNotes_numRows + Repeat1__numRows
> %>
> <%
> Dim TechNotes
> TechNotes = LCase(rsTechNotes("Detail"))
> %>
> <html>
> <head>
> <title>TechNotes Test</title>
> <meta http-equiv="Content-Type" content="text/html;
> charset=iso-8859-1">
> <link rel="stylesheet" href="../css/dkstyle.css" type="text/css">
> </head>
> <body bgcolor="#FFFFFF" text="#000000">
> <ul>
> <%
> While ((Repeat1__numRows <> 0) AND (NOT rsTechNotes.EOF))
> %>
> <span class="technotes"><%=replace(TechNotes, "-", "<li>")%></span>
> <%
>   Repeat1__index=Repeat1__index+1
>   Repeat1__numRows=Repeat1__numRows-1
>   rsTechNotes.MoveNext()
> Wend
> %>
> </ul>
> </body>
> </html>
> <%
> rsTechNotes.Close()
> %>
>
>
> <---CODE ENDS HERE--->



  Return to Index