CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   ASP (http://www.codingforums.com/forumdisplay.php?f=8)
-   -   Select all rows of data and compare values (http://www.codingforums.com/showthread.php?t=279052)

HalRau 10-24-2012 12:26 PM

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.

Old Pedant 10-24-2012 07:49 PM

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

HalRau 10-24-2012 10:55 PM

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

Old Pedant 10-25-2012 03:54 AM

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?

HalRau 10-25-2012 10:17 PM

Old Pedant, Sent you a screen capture of the database table via private message. Is that enough or do you need more?

Old Pedant 10-25-2012 11:15 PM

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?

HalRau 10-28-2012 01:00 PM

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


All times are GMT +1. The time now is 07:58 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.