Hello all!

I hope you guys can help me. I have an old ASP-based gaming event system running on my Windows Server 2008 R2 with ASPClassic enabled.

Everything works fine so. Until I try to calculate the statistics for an event.

Then I get this error:

Microsoft JET Database Engine error '80040e07'

Data type mismatch in criteria expression.
/wargames/includes/include.asp, line 3815
This is my code:

Code:
function RecalcGameRC(iGameID)
  ' Set up variables and structures
  dim sDebugResults
  dim SQL, rsMatches, rsPlayer, rsPoints, iMaxClubPlayers, iMaxGamesPlayed, iMinGamesHosted, iMaxAttritionRt
  dim iGames, vWarsList, index, iWarID, sMatchList, sPlayerName, iUniquePlayersIndex, vPlayerMatches, iMaxUPP, iMaxhrp, iMaxVictoryRt
  dim iRanking, iMaxPP, iAveragePlayerRanking, iPlayerID, iPoints, iKills, iDeaths, iMaxTotBases, iMaxTeamBases, iMaxAIBonus, iMaxAITeamBonus
  dim iVictoryRT, iAttritionRT, iMaxTeamPlayers, hostedrankingtemp, hostedrankingtemp1, iMatchBonus, iLMatchBonus, iPlayerMatchBonus, iTotAIRT, iTotBaseRT
  dim hrp
  set rsMatches = server.createobject("ADODB.Recordset")
  set rsPlayer  = server.createobject("ADODB.Recordset")
  set rsPoints  = server.createobject("ADODB.Recordset")
  application.lock
    dbConnection.execute "delete from war_playergamerankings where gameid=" & iGameID
    dbConnection.execute "delete from war_teamgamerankings where gameid=" & iGameID
  ' Now calculate the player and club rankings for the overall game
  SQL = "select sum(ranking) as ranking , username, memberid from war_playerwarrankings where warid in (select warid from war_wars where gameid=" & igameid & ") group by username, memberid"
  rsPlayer.open SQL, dbconnection, adopenforwardonly, adlockreadonly
  rsPoints.open "war_playergamerankings", dbconnection, adopenstatic, adlockoptimistic
  do until rsplayer.eof
    rspoints.addnew
    rspoints("gameid") = iGameID
    rspoints("username") = rsPlayer("username")
    rsPoints("memberid") = rsPlayer("memberid")
    rsPoints("ranking")  = rsplayer("ranking")
    rspoints.update
    rsplayer.movenext
  loop
  rsplayer.close
  rspoints.close
  SQL = "select sum(ranking) as ranking , teamname, teamtag, teamid from war_teamwarrankings where warid in (select warid from war_wars where gameid=" & igameid & ") group by teamname, teamid, teamtag"
  rsPlayer.open SQL, dbconnection, adopenforwardonly, adlockreadonly
  rsPoints.open "war_teamgamerankings", dbconnection, adopenstatic, adlockoptimistic
  do until rsplayer.eof
    rspoints.addnew
    rspoints("gameid") = iGameID
    rspoints("teamname") = rsPlayer("teamname")
    rsPoints("teamid")   = rsPlayer("teamid")
    rsPoints("teamtag")  = rsPlayer("teamtag")
    rsPoints("ranking")  = rsplayer("ranking")
    rspoints.update
    rsplayer.movenext
  loop
  rsplayer.close
  rspoints.close
  RecalcGameRC = sDebugResults
  application.unlock
end Function
Please help.