Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-24-2012, 12:26 PM   PM User | #1
HalRau
New Coder

 
Join Date: Oct 2007
Posts: 33
Thanks: 3
Thanked 0 Times in 0 Posts
HalRau is an unknown quantity at this point
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.
HalRau is offline   Reply With Quote
Old 10-24-2012, 07:49 PM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,579
Thanks: 62
Thanked 4,064 Times in 4,033 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
??? 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.
Old Pedant is offline   Reply With Quote
Old 10-24-2012, 10:55 PM   PM User | #3
HalRau
New Coder

 
Join Date: Oct 2007
Posts: 33
Thanks: 3
Thanked 0 Times in 0 Posts
HalRau is an unknown quantity at this point
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
HalRau is offline   Reply With Quote
Old 10-25-2012, 03:54 AM   PM User | #4
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,579
Thanks: 62
Thanked 4,064 Times in 4,033 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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.
Old Pedant is offline   Reply With Quote
Old 10-25-2012, 10:17 PM   PM User | #5
HalRau
New Coder

 
Join Date: Oct 2007
Posts: 33
Thanks: 3
Thanked 0 Times in 0 Posts
HalRau is an unknown quantity at this point
Old Pedant, Sent you a screen capture of the database table via private message. Is that enough or do you need more?
HalRau is offline   Reply With Quote
Old 10-25-2012, 11:15 PM   PM User | #6
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,579
Thanks: 62
Thanked 4,064 Times in 4,033 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
I replied to you in PM. Did you not get the reply?

Here...a copy of that message:
Quote:
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.
Old Pedant is offline   Reply With Quote
Old 10-28-2012, 01:00 PM   PM User | #7
HalRau
New Coder

 
Join Date: Oct 2007
Posts: 33
Thanks: 3
Thanked 0 Times in 0 Posts
HalRau is an unknown quantity at this point
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
HalRau is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:24 PM.


Advertisement
Log in to turn off these ads.