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.
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.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"
response.write "Already exist!"