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

If problem AHHH!!

Status
Not open for further replies.

BigBadDave

Programmer
May 31, 2001
1,069
EU
Why isn't this code working?

What I want to do is, if the value from Request("score") is equal to the value from the record set "score" then display a bold tag.


results=<%
Dim rs, data_source, con

data_source = &quot;Provider=Microsoft.Jet.OLEDB.4.0; Data Source=&quot; & Server.MapPath(&quot;scores.mdb&quot;)

Set con = Server.CreateObject(&quot;ADODB.Connection&quot;)
con.Open data_source
set rs = server.createobject(&quot;adodb.recordset&quot;)
rs.open &quot;select * from t_scores order by [score] desc&quot;, con

While Not rs.EOF

If rs(&quot;score&quot;) = Request(&quot;score&quot;) And rs(&quot;email&quot;) = Request(&quot;email&quot;) Then
Response.Write &quot;<b>&quot;
End If

Response.Write &quot;Score : &quot; & rs(&quot;score&quot;) & &quot;<br>First Name : &quot; & rs(&quot;fname&quot;) & &quot;<br>Last Name : &quot; & rs(&quot;lname&quot;) & &quot;<br>E-mail : <a href=&quot;&quot;mailto:&quot; & rs(&quot;email&quot;) & &quot;&quot;&quot;>&quot; & rs(&quot;email&quot;) & &quot;</a><br><br><br>&quot;

If rs(&quot;score&quot;) = Request(&quot;score&quot;) And rs(&quot;email&quot;) = Request(&quot;email&quot;) Then
Response.Write &quot;</b>&quot;
End If

rs.MoveNext
Wend
set rs = nothing
set con = nothing
%>
 
What happens?
I'd hazard a guess that referring to them properly may help.

rs.Fields(&quot;score&quot;) = Request.Form(&quot;score&quot;) <insert witticism here>
codestorm
 
I'm not sure what this result = ... stands for. Must be the return value of some function? Anyway, my suggestion is to use Trim function with your both recordset's and form's values when you compare them:


results=<%
Dim rs, data_source, con
data_source = &quot;Provider=Microsoft.Jet.OLEDB.4.0; Data Source=&quot; & Server.MapPath(&quot;scores.mdb&quot;)

Set con = Server.CreateObject(&quot;ADODB.Connection&quot;)
con.Open data_source
set rs = server.createobject(&quot;adodb.recordset&quot;)
rs.open &quot;select * from t_scores order by [score] desc&quot;, con

While Not rs.EOF

If Trim(rs(&quot;score&quot;)) = Trim(Request(&quot;score&quot;)) And Trim(rs(&quot;email&quot;)) = Trim(Request(&quot;email&quot;)) Then
Response.Write &quot;<b>&quot;
'End If -- you really don't need it here

Response.Write &quot;Score : &quot; & rs(&quot;score&quot;) & &quot;<br>First Name : &quot; & rs(&quot;fname&quot;) & &quot;<br>Last Name : &quot; & rs(&quot;lname&quot;) & &quot;<br>E-mail : <a href=&quot;&quot;mailto:&quot; & rs(&quot;email&quot;) & &quot;&quot;&quot;>&quot; & rs(&quot;email&quot;) & &quot;</a><br><br><br>&quot;

' If rs(&quot;score&quot;) = Request(&quot;score&quot;) And rs(&quot;email&quot;) = Request(&quot;email&quot;) Then -- you don't need this here either
Response.Write &quot;</b>&quot;
End If

rs.MoveNext
Wend
set rs = nothing
set con = nothing
%>
 
Thanx,
The trim function worked a treat!! Regards

Big Dave


** If I am wrong I am sorry, but i'm only trying to help!! **

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top