Expected Statement Error

G

Guest

Well first off I apologize for posting just about asp problems here in the
frontpage forums. but I have yet to find a good asp forum that actually
responds in decent time with good answers. and you guys are asp gurus :)
so here is a function I created but im getting an Expected End Error on the
last line of the function

Function Stats()
Dim wins, losses, points, team, strteamname, SQL
SQL = "Select * from tblchallenges where Agreed=True"
set rsInitial = dbConn.Execute(SQL)
While Not rsInital.eof

wins = 0
losses = 0 'set all values to 0 for each team
points = 0
team = rsInitial("BlueID") ' basically just to get a team ID and start at
the beginning of the database
strteamname = rsInitial("Blue")
SQLBlue = "Select * from tblchallenges where BlueID='" & team & "'" '
selects all records where the team is blue
set rsBlue = dbConn.Execute(SQLBlue)
While Not rsBlue.eof ' now we are going to cycle through each record adding
wins, losses, and points for each match for the blue
wins = wins + rsBlue("BlueWin")
losses = losses + rsBlue("BlueLose")
IF rsBlue("BlueWin") - rsBlue("BlueLose") < 0 Then
points = points - 1
Else
points = points + (rsBlue("BlueWin") - rsBlue("BlueLose"))
End IF
rsBlue.movenext
SQLRed = "Select * from tblchallenges where RedID='" & team & "'" ' select
all records where the above team was red
set rsRed = dbConn.Execute(SQLRed)
While Not rsRed.eof ' Now we cycle through every record adding up the values
for the red team with the blue ones
wins = wins + rsRed("RedWin")
losses = losses + rsRed("RedLose")
IF rsRed("RedWin") - rsRed("RedLose") < 0 Then
ponts = points - 1
Else
points = points + (rsRed("RedWin") - rsRed("RedLose"))
End If
rsRed.movenext
' now we are going to update the stats database based on this run of values
or make a new record for new teams
SQLStats = "select * from tblstats where TeamID='" & team & "'"
set rsStats = dbConn.Execute(SQLStats)
IF rsStats.eof Then
AddNewSQL = "INSERT into tblstats (TeamID, Team, Wins, Losses, Points,
Division) Values ('" & team & "', '" & strteamname & "', " & wins & ", " &
losses & ", " & points & ", 1"
set rsAddNew = dbConn.Execute("AddNewSQL")
Else
UpdateSQL = "Update tblstats set TeamID='" & team & "', Team='" &
strteamname & "', Wins=" & wins & ", Losses=" & losses & ", Points=" & points
& " Where TeamID='" & team & "'"
set rsUpdate = dbConn.Execute(UpdateSQL)
End IF
rsInitial.movenext
Stats = "complete"
End Function ' Expected Statement Error on this line.

I searched for all of my IF statement to be Closed and it all looked good to
me.
Thanks for the help, again
 
G

Guest

Correction the Error is Expected Statement. I wrote Expected End in the first
paragraph.
 
D

David Berry

The error appears at the end of the function because it is a function but
that doesn't necessarily mean that's where the problem lies. The best way
to find the exact spot that's causing the error is to take the code out of
the function and run it to see where it breaks. Then use Response.Write and
Response.End to track down the problem.

That being said, if the code you posted is what you're using then the
problem is in the AddNewSQL INSERT line. You have VALUES and an open paren
but there's no close paren at the end so it's an invalid line. (expected
end of statement would be the close). Ex:

AddNewSQL = "INSERT into tblstats (TeamID, Team, Wins, Losses, Points,
Division) Values ( <your variables> )"

Note: I didn't run the code to see if there might be more issues
 
S

Stefan B Rusynko

Plus other lots of other critical errors like:
1) opening all your connections for rs movement w/o setting the DB cursor type
2) unnneccarily opening the same table several times (and never closing any table)
2) opening at least 3 nested While statements w/o closing Wends
3) typo errors like at ponts = points - 1 should be points = points - 1
4) and logic errors (not reinitializing variables before opening another team)

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| The error appears at the end of the function because it is a function but
| that doesn't necessarily mean that's where the problem lies. The best way
| to find the exact spot that's causing the error is to take the code out of
| the function and run it to see where it breaks. Then use Response.Write and
| Response.End to track down the problem.
|
| That being said, if the code you posted is what you're using then the
| problem is in the AddNewSQL INSERT line. You have VALUES and an open paren
| but there's no close paren at the end so it's an invalid line. (expected
| end of statement would be the close). Ex:
|
| AddNewSQL = "INSERT into tblstats (TeamID, Team, Wins, Losses, Points,
| Division) Values ( <your variables> )"
|
| Note: I didn't run the code to see if there might be more issues
|
| --
| David Berry - MCP
| Microsoft MVP - FrontPage
| FrontPage Support: http://www.frontpagemvps.com/
| -----------------------------------
| To assist you in getting the best answers for FrontPage support see:
| http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| -----------------------------------
|
| | > Well first off I apologize for posting just about asp problems here in the
| > frontpage forums. but I have yet to find a good asp forum that actually
| > responds in decent time with good answers. and you guys are asp gurus :)
| > so here is a function I created but im getting an Expected End Error on
| > the
| > last line of the function
| >
| > Function Stats()
| > Dim wins, losses, points, team, strteamname, SQL
| > SQL = "Select * from tblchallenges where Agreed=True"
| > set rsInitial = dbConn.Execute(SQL)
| > While Not rsInital.eof
| >
| > wins = 0
| > losses = 0 'set all values to 0 for each team
| > points = 0
| > team = rsInitial("BlueID") ' basically just to get a team ID and start at
| > the beginning of the database
| > strteamname = rsInitial("Blue")
| > SQLBlue = "Select * from tblchallenges where BlueID='" & team & "'" '
| > selects all records where the team is blue
| > set rsBlue = dbConn.Execute(SQLBlue)
| > While Not rsBlue.eof ' now we are going to cycle through each record
| > adding
| > wins, losses, and points for each match for the blue
| > wins = wins + rsBlue("BlueWin")
| > losses = losses + rsBlue("BlueLose")
| > IF rsBlue("BlueWin") - rsBlue("BlueLose") < 0 Then
| > points = points - 1
| > Else
| > points = points + (rsBlue("BlueWin") - rsBlue("BlueLose"))
| > End IF
| > rsBlue.movenext
| > SQLRed = "Select * from tblchallenges where RedID='" & team & "'" ' select
| > all records where the above team was red
| > set rsRed = dbConn.Execute(SQLRed)
| > While Not rsRed.eof ' Now we cycle through every record adding up the
| > values
| > for the red team with the blue ones
| > wins = wins + rsRed("RedWin")
| > losses = losses + rsRed("RedLose")
| > IF rsRed("RedWin") - rsRed("RedLose") < 0 Then
| > ponts = points - 1
| > Else
| > points = points + (rsRed("RedWin") - rsRed("RedLose"))
| > End If
| > rsRed.movenext
| > ' now we are going to update the stats database based on this run of
| > values
| > or make a new record for new teams
| > SQLStats = "select * from tblstats where TeamID='" & team & "'"
| > set rsStats = dbConn.Execute(SQLStats)
| > IF rsStats.eof Then
| > AddNewSQL = "INSERT into tblstats (TeamID, Team, Wins, Losses, Points,
| > Division) Values ('" & team & "', '" & strteamname & "', " & wins & ", " &
| > losses & ", " & points & ", 1"
| > set rsAddNew = dbConn.Execute("AddNewSQL")
| > Else
| > UpdateSQL = "Update tblstats set TeamID='" & team & "', Team='" &
| > strteamname & "', Wins=" & wins & ", Losses=" & losses & ", Points=" &
| > points
| > & " Where TeamID='" & team & "'"
| > set rsUpdate = dbConn.Execute(UpdateSQL)
| > End IF
| > rsInitial.movenext
| > Stats = "complete"
| > End Function ' Expected Statement Error on this line.
| >
| > I searched for all of my IF statement to be Closed and it all looked good
| > to
| > me.
| > Thanks for the help, again
|
|
 
D

David Berry

A note on the While ... Wends, I prefer using

Do while ...

rs.movenext
loop

--
David Berry - MCP
Microsoft MVP - FrontPage
FrontPage Support: http://www.frontpagemvps.com/
-----------------------------------
To assist you in getting the best answers for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
-----------------------------------

Stefan B Rusynko said:
Plus other lots of other critical errors like:
1) opening all your connections for rs movement w/o setting the DB cursor
type
2) unnneccarily opening the same table several times (and never closing
any table)
2) opening at least 3 nested While statements w/o closing Wends
3) typo errors like at ponts = points - 1 should be points = points - 1
4) and logic errors (not reinitializing variables before opening another
team)

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| The error appears at the end of the function because it is a function
but
| that doesn't necessarily mean that's where the problem lies. The best
way
| to find the exact spot that's causing the error is to take the code out
of
| the function and run it to see where it breaks. Then use Response.Write
and
| Response.End to track down the problem.
|
| That being said, if the code you posted is what you're using then the
| problem is in the AddNewSQL INSERT line. You have VALUES and an open
paren
| but there's no close paren at the end so it's an invalid line.
(expected
| end of statement would be the close). Ex:
|
| AddNewSQL = "INSERT into tblstats (TeamID, Team, Wins, Losses, Points,
| Division) Values ( <your variables> )"
|
| Note: I didn't run the code to see if there might be more issues
|
| --
| David Berry - MCP
| Microsoft MVP - FrontPage
| FrontPage Support: http://www.frontpagemvps.com/
| -----------------------------------
| To assist you in getting the best answers for FrontPage support see:
| http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| -----------------------------------
|
| | > Well first off I apologize for posting just about asp problems here in
the
| > frontpage forums. but I have yet to find a good asp forum that
actually
| > responds in decent time with good answers. and you guys are asp gurus
:)
| > so here is a function I created but im getting an Expected End Error
on
| > the
| > last line of the function
| >
| > Function Stats()
| > Dim wins, losses, points, team, strteamname, SQL
| > SQL = "Select * from tblchallenges where Agreed=True"
| > set rsInitial = dbConn.Execute(SQL)
| > While Not rsInital.eof
| >
| > wins = 0
| > losses = 0 'set all values to 0 for each team
| > points = 0
| > team = rsInitial("BlueID") ' basically just to get a team ID and start
at
| > the beginning of the database
| > strteamname = rsInitial("Blue")
| > SQLBlue = "Select * from tblchallenges where BlueID='" & team & "'" '
| > selects all records where the team is blue
| > set rsBlue = dbConn.Execute(SQLBlue)
| > While Not rsBlue.eof ' now we are going to cycle through each record
| > adding
| > wins, losses, and points for each match for the blue
| > wins = wins + rsBlue("BlueWin")
| > losses = losses + rsBlue("BlueLose")
| > IF rsBlue("BlueWin") - rsBlue("BlueLose") < 0 Then
| > points = points - 1
| > Else
| > points = points + (rsBlue("BlueWin") - rsBlue("BlueLose"))
| > End IF
| > rsBlue.movenext
| > SQLRed = "Select * from tblchallenges where RedID='" & team & "'" '
select
| > all records where the above team was red
| > set rsRed = dbConn.Execute(SQLRed)
| > While Not rsRed.eof ' Now we cycle through every record adding up the
| > values
| > for the red team with the blue ones
| > wins = wins + rsRed("RedWin")
| > losses = losses + rsRed("RedLose")
| > IF rsRed("RedWin") - rsRed("RedLose") < 0 Then
| > ponts = points - 1
| > Else
| > points = points + (rsRed("RedWin") - rsRed("RedLose"))
| > End If
| > rsRed.movenext
| > ' now we are going to update the stats database based on this run of
| > values
| > or make a new record for new teams
| > SQLStats = "select * from tblstats where TeamID='" & team & "'"
| > set rsStats = dbConn.Execute(SQLStats)
| > IF rsStats.eof Then
| > AddNewSQL = "INSERT into tblstats (TeamID, Team, Wins, Losses, Points,
| > Division) Values ('" & team & "', '" & strteamname & "', " & wins & ",
" &
| > losses & ", " & points & ", 1"
| > set rsAddNew = dbConn.Execute("AddNewSQL")
| > Else
| > UpdateSQL = "Update tblstats set TeamID='" & team & "', Team='" &
| > strteamname & "', Wins=" & wins & ", Losses=" & losses & ", Points=" &
| > points
| > & " Where TeamID='" & team & "'"
| > set rsUpdate = dbConn.Execute(UpdateSQL)
| > End IF
| > rsInitial.movenext
| > Stats = "complete"
| > End Function ' Expected Statement Error on this line.
| >
| > I searched for all of my IF statement to be Closed and it all looked
good
| > to
| > me.
| > Thanks for the help, again
|
|
 
Top