Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting close to giving up on ASP...getting null values from good data

Status
Not open for further replies.

wvmikep

Programmer
Feb 26, 2001
35
US
I've got the following code....it returns null values for many of the columns in the query only ifI leave the IF and SELECT in the DO WHILE loop. If I take them out, things SEEM to work. However, that doesn't help.

There's nothing wrong with the db because I wrote a version in ColdFusion and it works perfectly.

<%@ Language = VBSCRIPT %>
<% Option Explicit %>
<!--#include file=&quot;adovbs.inc&quot;-->
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>

<html>
<head>
<title>Untitled</title>
<!--#include file=&quot;stylesheet.css&quot;-->
</head>

<body bgcolor=&quot;#CFB89F&quot; leftmargin=&quot;0&quot; topmargin=&quot;0&quot;>
<!--#include file=&quot;header.asp&quot;-->
<%
Dim objConnTP
Set objConnTP = Server.CreateObject(&quot;ADODB.Connection&quot;)
objConnTP.ConnectionString = &quot;Provider=MSDASQL;DSN=techies;UID=deleted;password=deleted;&quot;
objConnTP.Open

Dim strSQL
strSQL = &quot;SELECT TOP 6 ID, art_title, art_content, art_subject, art_page, art_next_page, art_macpc, art_author from thearticles WHERE art_parent = 0&quot;

Dim objRS
Set objRS = Server.CreateObject(&quot;ADODB.Recordset&quot;)
'objRS.MaxRecords = 6
objRS.Open strSQL, objConnTP

Dim strSubject, strMacPC, strLabel

Do While Not objRS.EOF
If (objRS(&quot;art_macpc&quot;) = 1) then
strMacPC = &quot;In PC &quot;
strLabel = &quot;pc&quot;
Elseif (objRS(&quot;art_macpc&quot;) = 2) then
strMacPC = &quot;In Mac &quot;
strLabel = &quot;mac&quot;
Else
strMacPC = &quot;In PC/Mac &quot;
strLabel = &quot;pcmac&quot;
End If

Select Case objRS(&quot;art_subject&quot;)
Case 1
strSubject = &quot;Hardware&quot;
strLabel = strLabel & &quot;hardware.png&quot;
Case 2
strSubject = &quot;Apps&quot;
strLabel = strLabel & &quot;apps.png&quot;
Case 3
strSubject = &quot;Games&quot;
strLabel = strLabel & &quot;games.png&quot;
Case 4
strSubject = &quot;In ASP Development&quot;
strMacPC = &quot;&quot;
strLabel = strLabel & &quot;asp.png&quot;
Case Else
strSubject = &quot;In ColdFusion Development&quot;
strMacPC = &quot;&quot;
strLabel = strLabel & &quot;cf.png&quot;
End Select
%><br>
<table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; width=&quot;400&quot;>
<tr>
<td colspan=&quot;3&quot; width=&quot;400&quot;><a href=&quot;subject.asp?subject=<%= objRS(&quot;art_subject&quot;) %>&macpc=<%= objRS(&quot;art_macpc&quot;) %>&quot;><img src=&quot;images/label_<%= strLabel %>&quot; width=175 height=20 alt=&quot;Latest Article&quot; border=&quot;0&quot;></a></td>
</tr>
<tr>
<td colspan=&quot;3&quot; width=&quot;400&quot; bgcolor=&quot;#60000F&quot;><img src=&quot;images/blank.gif&quot; width=1 height=1 alt=&quot;&quot; border=&quot;0&quot;></td>
</tr>
<tr>
<td width=&quot;1&quot; bgcolor=&quot;#60000F&quot;><img src=&quot;images/blank.gif&quot; width=1 height=1 alt=&quot;&quot; border=&quot;0&quot;></td>
<td width=&quot;398&quot;><table><tr><td><font class=&quot;basictext&quot;>
<%
Response.Write &quot;<a href='article.asp?id=&quot; & objRS(&quot;ID&quot;) & &quot;&page=&quot; & objRS(&quot;art_page&quot;) &&quot;'><b>&quot; & objRS(&quot;art_title&quot;) & &quot;</b></a><br>&quot;
Response.Write objRS(&quot;art_content&quot;) & &quot;<br>&quot;
%>
</font></td></tr></table></td>
<td width=&quot;1&quot; bgcolor=&quot;#60000F&quot;><img src=&quot;images/blank.gif&quot; width=1 height=1 alt=&quot;&quot; border=&quot;0&quot;></td>
</tr>
<tr>
<td colspan=&quot;3&quot; width=&quot;400&quot; bgcolor=&quot;#60000F&quot;><img src=&quot;images/blank.gif&quot; width=1 height=1 alt=&quot;&quot; border=&quot;0&quot;></td>
</tr>
</table>
<%

objRS.MoveNext
Loop

objRS.Close
Set objRS = Nothing
objConnTP.Close
Set objConnTP = Nothing

%>
<br>
<!--#include file=&quot;footer.asp&quot;-->

</body>
</html>
------------------------------------
&quot;Unclean beast! Get thee down! Be thou consumed by the fires that made thee!&quot; - Brother Jacobus in Dragonslayer
 
I'm not to familiar with SQL, but I'm not sure how the SELECT TOP 6 works with an ASP recordset. Try it without and just run through the recordset six times. Harold Blackorby
hblackorby@scoreinteractive.com
St. Louis, MO
 
Tried that. Same result. ------------------------------------
&quot;Unclean beast! Get thee down! Be thou consumed by the fires that made thee!&quot; - Brother Jacobus in Dragonslayer
 
I've had a similar problem on a few projects. I found the problem to be somewhere in my hyperlink tags when I placed so many variables to be posted to the submitting page.

Check here:
Response.Write &quot;<a href='article.asp?id=&quot; & objRS(&quot;ID&quot;) & &quot;&page=&quot; & objRS(&quot;art_page&quot;) &&quot;'><b>&quot; & objRS(&quot;art_title&quot;) & &quot;</b></a><br>&quot;
Response.Write objRS(&quot;art_content&quot;) & &quot;<br>&quot;

Are you sure this coding is correct? I found some slight alterations necessary in coding the href=&quot;x&quot; using Response.Write.

A suggestion I'll pass on, given to me by other programmers much more experienced than I am concerning your design: Only place an id tag in the hyperlink, then on the submitted page, requery the database seeking the information for only that record using the single passed variable. I've been told that is a faster way than passing multiple variables.

Mark
 
Funny thing is, the oddities occur before the links are built. ------------------------------------
&quot;Unclean beast! Get thee down! Be thou consumed by the fires that made thee!&quot; - Brother Jacobus in Dragonslayer
 
is there a zero (0) located in &quot;art_parent&quot; in the table? if there is no zero and your query is looking for that, it would have to values match where art_parent = 0, therefore would not enter anything for strMacPC, or strLabel.

Also, try trouble shooting it a little more. Is it BOTH the if-else AND the SELECT statement, or is it only the if-else, or only the select statement variables that are null?

put a response.write statement after each writing the variables to the page to see if they come up after each individual section. I don't have your db, and I don't have your page setup here, but you need to look at it more logically and debug it. piece by piece. There's nothing wrong with ASP code. If there were, do you think it would be so widely used? It's not ASP, it's your code...so don't be so willing to give up on it. What you're actually doing is giving up on yourself.

Ovatvvon
 
It works if I get rid of both the IF-ELSE and the SELECT. There's nothing wrong with either the SQL or the data as I wrote a version, using the same logic, in ColdFusion and it worked perfectly. ------------------------------------
&quot;Unclean beast! Get thee down! Be thou consumed by the fires that made thee!&quot; - Brother Jacobus in Dragonslayer
 
Did you try to debug it yet? use a response.write below each to write the values of the variables before going to another page...see if they are even set there
 
Yeah, that's how I found that removing the IF and the SELECT removed the symptoms. With them in, even having the response.write above the if and select gave me nulls. ------------------------------------
&quot;Unclean beast! Get thee down! Be thou consumed by the fires that made thee!&quot; - Brother Jacobus in Dragonslayer
 
don't put the response.write ABOVE the statement...of course it'll be null...put it below after it's selected the input for the variables.
 
no, no, no.....it's above the IF and SELECT, but in the DO WHILE...LOOP, which is after the SQL statement is executed. ------------------------------------
&quot;Unclean beast! Get thee down! Be thou consumed by the fires that made thee!&quot; - Brother Jacobus in Dragonslayer
 
Hey,
I will just have to see it to totally understand. Are you willing to email me a copy of your page and database?
Jim
jimbob550@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top