Simple IF statment problem I hope

Simple IF statment problem I hope

am 11.11.2005 00:40:02 von KS

I'm getting an ID number from a list of teams. Then I have a table with 4
fields: id, awayteam, hometeam, result.

When I run my loop, it seems like I'm losing the teamid field for some
reason.
The part with the IF statment always defaults to the ELSE.

Any suggestions?

TIA

teamid = Request.Querystring("TeamID")

SQL = "SELECT * FROM Games05 WHERE AwayTeam = " & teamid & " OR HomeTeam = "
& teamid

Response.Write("

")

While NOT RS.EOF

Response.Write("")
Response.Write("")
Response.Write("")
Response.Write("")
IF id = RS.Fields(1) THEN
Response.Write("")
ELSE
Response.Write("")
END IF
Response.Write("")

RS.MoveNext
WEnd

Response.Write("
" & RS.Fields(1) & "" & RS.Fields(2) & "" & RS.Fields(3) & "AwayHome
")

%>

Re: Simple IF statment problem I hope

am 11.11.2005 00:50:44 von McKirahan

"ks" wrote in message
news:A31CAB6E-C978-4A50-BE54-198E6D71666B@microsoft.com...
> I'm getting an ID number from a list of teams. Then I have a table with 4
> fields: id, awayteam, hometeam, result.
>
> When I run my loop, it seems like I'm losing the teamid field for some
> reason.
> The part with the IF statment always defaults to the ELSE.
>
> Any suggestions?
>
> TIA
>
> teamid = Request.Querystring("TeamID")
>
> SQL = "SELECT * FROM Games05 WHERE AwayTeam = " & teamid & " OR HomeTeam =
"
> & teamid
>
> Response.Write("

")
>
> While NOT RS.EOF
>
> Response.Write("")
> Response.Write("")
> Response.Write("")
> Response.Write("")
> IF id = RS.Fields(1) THEN
> Response.Write("")
> ELSE
> Response.Write("")
> END IF
> Response.Write("")
>
> RS.MoveNext
> WEnd
>
> Response.Write("
" & RS.Fields(1) & "" & RS.Fields(2) & "" & RS.Fields(3) & "AwayHome
")
>
> %>
>

Per your Response.Write, is the value of RS.Fields(1) what you expect.

Perhaps it fails as you're comparing a number to a string; try:
IF id = CInt(RS.Fields(1).Value) THEN

Re: Simple IF statment problem I hope

am 11.11.2005 09:35:28 von exjxw.hannivoort

=?Utf-8?B?a3M=?= wrote on 11 nov 2005 in
microsoft.public.inetserver.asp.db:

> When I run my loop, it seems like I'm losing the teamid field for some
> reason.
> The part with the IF statment always defaults to the ELSE.
>
> Any suggestions?
>
> TIA
>
> teamid = Request.Querystring("TeamID")
>
> SQL = "SELECT * FROM Games05 WHERE AwayTeam = " & teamid & " OR
> HomeTeam = " & teamid
>
> Response.Write("

")
>
> While NOT RS.EOF
>
> Response.Write("")
> Response.Write("")
> Response.Write("")
> Response.Write("")
> IF id = RS.Fields(1) THEN
>

[1 the "set rs = dbxx.execute(SQL)" line fails]

2 the variable "id" is is not defined, so defaulds to ""
and the condition is always "false",
should be "teamid"

3 teamid = RS.Fields(1) could compare strings, where you mean numeric,
because Request.Querystring("TeamID") returns a string that could be
"000055"
so try:
IF 1*teamid = RS.Fields(1) THEN


--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

" & RS.Fields(1) & "" & RS.Fields(2) & "" & RS.Fields(3) & "