troubleshooting Question

ASP Classic SQL Server LIKE Query not working properly

Avatar of Wayne Barron
Wayne BarronFlag for United States of America asked on
ASPMicrosoft SQL ServerVisual Basic Classic
3 Comments1 Solution200 ViewsLast Modified:
Hello All;

The record exist in the database, in both columns, so, it SHOULD state that the record exist.
However, it is not, it is stating that the record does not exist.
Even though it is there.

We are looking at BOTH columns, as the record will exist, ONLY if both columns have the correct information.

The PageList Column, this will have different entries in it like so.

Movies_(Romance) / Movies_(Horror) / Movies_(Comedy) / Movies_(Disney) / Movies_(Drama)

So, that is why I am using the LIKE, so that I can check and see if the "Movies_(Romance)" exist in the column. If not, then add it, else, NOT.

Can someone please shine some light on this?
As I am at my wits end, I do not know what in the world is going wrong.
I got the same code to work in another part of the page, however, I cannot get this one to function.


One last thing.
I ran the same Query inside of SSMS, and it ran perfectly, and like expected, it is just NOT working in the script below.

Carrzkiss

Code:
getTitle = "Movies_(Romance)"
SongName = "Let Me Know"
<%
' Both getTheSong and getTitle are coming from form fields.'
getTheSong = replace(SongName," ","_")
strTerm = "%" & getTitle & "%"

Set sqlUsage = Server.CreateObject("ADODB.Command")
sqlUsage.ActiveConnection=Conn
sqlUsage.Prepared = true
sqlUsage.commandtext="SELECT SongTitle, PageList FROM Songs WHERE SongTitle=? and PageList like ?"
sqlUsage.Parameters.Append sqlUsage.CreateParameter("@SongTitle", adVarChar, adParamInput, 250, getTheSong)
sqlUsage.Parameters.Append sqlUsage.CreateParameter("@PageList", adVarChar, adParamInput, 250, strTerm) 
set rschSong = sqlUsage.execute
if rschSong.eof then
response.write "Does not exist"
else
response.write "Already exist!"
end if
%>

Open in new window

ASKER CERTIFIED SOLUTION
Wayne Barron
Author, Web Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Top Expert 2009

The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 3 Comments.
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>

Mike

Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 3 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004