B
Bill
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
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