Print Page | Close Window

Help on simple SQL issue

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=2765
Printed Date: 29 March 2026 at 8:18am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Help on simple SQL issue
Posted By: Chris
Subject: Help on simple SQL issue
Date Posted: 16 May 2003 at 11:02am

What's wrong with my SQL here?

I want to retrieve a specific (pre-known) post from the WWF7 db.

strSQL = "SELECT TOP 1 Thread_ID, Topic_ID, Message, Message_date FROM "
strSQL = strSQL & "tblThread WHERE "
strSQL = strSQL & "Topic_ID = 128 " 
strSQL = strSQL & "Thread_ID = 391"
strSQL = strSQL & " ORDER BY Message_date DESC"
Set rsThreads = connectForum.Execute(strSQL)

I always get the same (wrong) post from Topic_ID = 128, namely the last one posted. Even if I change the last SQL-line to ORDER BY Message_date ASC the result is the same.

I'd really appriciate any suggestions!

Chris




Replies:
Posted By: ljamal
Date Posted: 16 May 2003 at 11:14am
Does the thread have more than one post?
The line
strSQL = strSQL & "Thread_ID = 391"
is redundant as the Topic_ID is the primary key so specifying it should guarantee the same posts as with the strSQL = strSQL & "Thread_ID = 391"


Posted By: MorningZ
Date Posted: 16 May 2003 at 11:30am

strSQL = strSQL & " AND Thread_ID = 391"

Theres no way your posted SQL script should have worked, the above should

and if it doesn't, then Response.Write (and Response.End right after that) out the variable holding the script and confirm its correct



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: fernan82
Date Posted: 16 May 2003 at 2:58pm

strSQL = "SELECT Thread_ID,  Message, Message_date "
strSQL = strSQL & "FROM tblThread "
strSQL = strSQL & "WHERE Thread_ID = 391"

The above is all you need to get that post...



-------------
FeRnAN
http://www.danasoft.com/">


Posted By: Chris
Date Posted: 16 May 2003 at 3:20pm

Thanks!

But when I display the Message an annoying tag is attached to it, like User234234,2342525622231. How do I get rid of that?

I now use
strMessage = rsThreads.Fields("Message").Value

for putting the Message in variable strMessage and

Response.Write(vbCrLf & strMessage & vbCrLf)

for displaying it. Any other (better) suggestions?

Chris

 



Posted By: fernan82
Date Posted: 16 May 2003 at 5:56pm

try

strMessage = rsThreads("Message")



-------------
FeRnAN
http://www.danasoft.com/">


Posted By: Chris
Date Posted: 16 May 2003 at 6:43pm

Nope, that doesn't make the trick. The trace of the user who posted the message seem to be smuggled into strMessage anyway, a really ugly string like User312331,312512512312

There must be an evil Ghost inside my machine...  

Chris



Posted By: fernan82
Date Posted: 16 May 2003 at 7:49pm
post the full code and a link to the page...

-------------
FeRnAN
http://www.danasoft.com/">



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net