Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Oct 2007
    Posts
    33
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Select all rows of data and compare values

    Hello, I'm trying to modify some code to select all rows of records in a access database table. I am seeing only the first record.
    Here is the code:
    Code:
    <% 
    Set objConn = Server.CreateObject("ADODB.Connection")
    objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Hosting\wayn4797\access_db\Commentsdb.mdb;"
    objConn.Open
    Set objRs4=Server.CreateObject("ADODB.RecordSet")
    sql4="SELECT * FROM DWUOComLog WHERE Com_live = True ORDER BY Com_Date ASC"
    
    objRs4.Open sql4, objConn, 1, 1, 1
     %>
    
    <%
    Dim Repeat1__numRows
    Dim Repeat1__index
    
    Repeat1__numRows = -1
    Repeat1__index = 0
    Recordset1_numRows = objRs4_numRows + Repeat1__numRows
    %>
    
    <% response.Write objRs4("Article_ID") %>
    Here is what I am using to compare a stored value Article_ID with a set value.

    Code:
    <%if (objRs4.Fields.Item("Article_ID").Value)="10-1" then%> Yes 
     <% ElseIf trim((objRs4.Fields.Item("Article_ID").Value))<>"10-1" Then %> No
          <% End If %> Article ID = <%=(objRs4.Fields.Item("Article_ID").Value)%>
    The above code is repeated using different variables through out the page.
    I am only seeing the value of the first record. Never any more. What am I doing wrong?
    Thanks in advance for your help.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,664
    Thanks
    80
    Thanked 4,643 Times in 4,605 Posts
    ??? You don't show any *LOOP* on the recordset, so of course you will only see one record.

    You are using NightmarishStalker code (AKA the misnamed DreamWeaver) but apparently you have modified it. As bad as DrunkWalker code normally is, it would do the loop for you.

    But you also say "The above code is repeated using different variables through out the page" and that tells me that your code is horribly inefficient.

    Maybe if you showed some sample data from the DB table and some sample output you are trying to achieve we could toss out the DoofusWhacker code and give you something usable.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New Coder
    Join Date
    Oct 2007
    Posts
    33
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Hi Old Pedant,
    I am all for getting rid of the DrunkWalker code.

    What I want to do is simply loop through the database table and those recordsets that have Com_Live = True and then use the value of Article_ID which is a text field to show whether there is a comment been posted to that article or not.

    Something like this around each story in the newsletter, minus the code,
    if the value of Article_ID = "10-1" than response.write("Read/Write Comments")
    ElseIf the value of Article_ID <> "10-1" than response.write("Write a Comment")
    End if

    Here is a link to the page I am working on
    http://lifeslegacys.com/DWUONewsletter/index.asp

    Thanks for your suggestions and help

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,664
    Thanks
    80
    Thanked 4,643 Times in 4,605 Posts
    Can you show me a dump of the table? Just show me 3 or 4 records from the table would be enough. And for the text field that holds the actual comment it's okay to chop it off to just a few characters.

    Are the articles coming from a DB table, as well? If so what is the structure of that table? That is, what are the field names and types?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #5
    New Coder
    Join Date
    Oct 2007
    Posts
    33
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Old Pedant, Sent you a screen capture of the database table via private message. Is that enough or do you need more?

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,664
    Thanks
    80
    Thanked 4,643 Times in 4,605 Posts
    I replied to you in PM. Did you not get the reply?

    Here...a copy of that message:
    That's fine.

    You didn't answer the question about the articles. Do *they* come from a DB table, as well? If not, how do you decide which articles to show on the page? And how do you decide the order on the page?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #7
    New Coder
    Join Date
    Oct 2007
    Posts
    33
    Thanks
    3
    Thanked 0 Times in 0 Posts
    The articles are not in a database. They are entered in html in the pages' three columns. I manually assign article ID values to each one sequentially - center column, left side column, right side column. The manually coded article ID is then part of the link passed to the comments.asp. Example: comments.asp?Article_ID=10-10&Article_MoYr=Oct2012&Article_title=The Magic of Music"

    Basically all I am trying to do in alert the reader of the article if comments have been made and approved or not based on whether or not a comment corresponding to that article exists in the comments db table.

    Hope this helps


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •