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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sql select

Status
Not open for further replies.

sparky68

Programmer
Feb 27, 2002
11
0
0
US
I’m trying to pick a different sql line when a querystring exists or not…heres the code:

if request.querystring(&quot;ID&quot;) <> &quot;&quot; then
recordtoview = request.querystring(&quot;ID&quot;)
strsql = &quot;SELECT * from news ORDER BY news.newsDate where news.newsid =&quot; & recordtoview & &quot;;&quot; else
strsql = &quot;SELECT * from news ORDER BY news.newsDate DESC&quot;
end if

the first time you goto to page it should use the else part, since “id” doesn’t exist. If you click a different article it adds id to url and reloads page. Eventhou the url is right, it still shows the else part…
 
Try this:
Code:
If NOT request.querystring(&quot;ID&quot;) &quot;&quot; then
    recordtoview = request.querystring(&quot;ID&quot;)
 strsql = &quot;SELECT * from news ORDER BY news.newsDate where news.newsid =&quot; & recordtoview & &quot;;&quot; 
else
    strsql = &quot;SELECT * from news ORDER BY news.newsDate DESC&quot;

End if

Try &quot;NOT&quot; instead of <> also...do you have your excute statement in the code as well?
 
Try this:
Code:
If NOT request.querystring(&quot;ID&quot;) &quot;&quot; then
    recordtoview = request.querystring(&quot;ID&quot;)
 strsql = &quot;SELECT * from news ORDER BY news.newsDate where news.newsid =&quot; & recordtoview & &quot;;&quot; 
else
    strsql = &quot;SELECT * from news ORDER BY news.newsDate DESC&quot;

End if

Try &quot;NOT&quot; instead of <> also...do you have your excute statement in the code as well?
 
That is weird, I got an error when I submitted it...saying it took to long to submit the reply...then it ended up posting it twice? ... I know I only clicked once on that button.. hmm
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top