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

Trying to make a search work in asp page

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I’m trying to lit web user to enter a keyword. The system then produce table includes movie title, release year, rating, and review but for all movies with that keyword in the title.

But I’m missing something can anyone help



============================================
<html>
<H1>Movies Genres list</H1>

<%
Dim adOpenForwardOnly, adLockReadOnly, adCmdTable
adOpenForwardOnly=0
adLockReadOnly=1
adCmdTable=2
adCmdText=1

Dim objConn, GenRS, GenSQL,vGENRE
Set objConn = Server.CreateObject(&quot;ADODB.Connection&quot;)
Set GenRS = Server.CreateObject(&quot;ADODB.Recordset&quot;)


vGENRE = request.form(&quot;title&quot;)





objConn.Open &quot;File Name=f:\Studentwebs\salqahtan\myconnection.udl&quot;


genSQL = &quot;Select title,released,rating,review from movies where title like upper('%&vGENRE&%')&quot;


GenRS.open GenSQL, objConn, adOpenForwardOnly, adLockReadOnly, AdCmdText

'here is my problem

response.write(&quot;<form action=' method='POST'>&quot;)

vGENRE=&quot;title&quot;
genRS.find vGENRE
response.write(&quot;<INPUT TYPE=TEXT NAME='title' size=25>&quot;)
response.write(&quot;</select>&quot;)
response.write(&quot;<input type='submit' value='<-- Search for movie'>&quot;)
response.write(&quot;</form>&quot;)

%>


<%

response.write(&quot;<body style='border-style: outset; border-width: 2'><table border=1 cellspacing=1 width=100% id='AutoNumber1' style=color: #FFFFFF; border-style: groove; border-width: 3 bordercolor=#DFCAAA bordercolorlight=#C0C0C0 bordercolordark=#FFFFFF bgcolor=#D7EAE7>&quot;)
response.write(&quot;<TR>&quot;)
response.write(&quot;<TD align=left height=20 width='55%' bgcolor='#A7D1CB'>&quot;)
response.write(&quot;<big><font color='#5E85B0'>Title</font></big></TD>&quot;)
response.write(&quot;<TD align=left height=20 width='15%' bgcolor='#A7D1CB'>&quot;)
response.write(&quot;<big><font color='#5E85B0'>Released Year</font></big></TD>&quot;)
response.write(&quot;<TD align=left height=20 width='20%' bgcolor='#A7D1CB'>&quot;)
response.write(&quot;<big><font color='#5E85B0'>Rating</font></big></TD>&quot;)
response.write(&quot;<TD align=left height=20 width='10%' bgcolor='#A7D1CB'>&quot;)
response.write(&quot;<big><font color='#5E85B0'>Review</font></big></TD>&quot;)
response.write(&quot;</TR>&quot;)
%> <%
while not genRS.eof

response.write(&quot;<TR>&quot;)
response.write(&quot;<TD>&quot; & movgRS(&quot;title&quot;) & &quot;</TD>&quot;)
response.write(&quot;<TD>&quot; & movgRS(&quot;released&quot;) & &quot;</TD>&quot;)
response.write(&quot;<TD>&quot; & movgRS(&quot;rating&quot;) & &quot;</TD>&quot;)
response.write(&quot;<TD>&quot; & movgRS(&quot;review&quot;) & &quot;</TD>&quot;)
response.write(&quot;</TR>&quot;)
genRS.movenext
Wend

response.write(&quot;</table></BIG>&quot;)

GenRS.close
objConn.close
Set GenRS = Nothing
Set objConn = Nothing

%>

<BR><HR>
</HTML>
 
You wrote:

genSQL = &quot;Select title,released,rating,review from movies where title like upper('%&vGENRE&%')&quot;

this is wrong as you have included vGENRE as part of the string instead of its actual value

change to

genSQL = &quot;Select title,released,rating,review from movies where title like upper('%&quot;&vGENRE&&quot;%')&quot;
 
You wrote:

genSQL = &quot;Select title,released,rating,review from movies where title like upper('%&vGENRE&%')&quot;

this is wrong as you have included vGENRE as part of the string instead of its actual value

change to

genSQL = &quot;Select title,released,rating,review from movies where title like upper('%&quot;& vGENRE &&quot;%')&quot;
 
also, title may be a reserved word so if the above didnt work try changing the form field name from title to something like filmTitle, whatever
 
One thing

when open the page every movie will be there
i want the table empty please
 
test to see if vGenre has a value before writing out the table, if it has a value then you know a search is being performed so you need to display the table, if no data then dont response.write the table out
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top