ok. faccio così ma mi da errore:
prima controllo chi ha fatto più di due gare e se le ha fatte estraggo il punteggio massimo. una volta estratto il punteggio massimo faccio la sql di update per scarto N. qui funziona. ma appena faccio "else" per fare l'update in caso contrario, cioè dei risultati diversi dal punteggio massimo, va in errore. a fianco della riga ho messo (riga che va in errore).
codice:
SQL = "SELECT punteggi.codiceGiocatore, Count(Gare.CodiceCampo) AS contacampo, Gare.CodiceCampo "
SQL = SQL & " FROM ["&percorsoserver&"].Gare INNER JOIN punteggi ON Gare.CodiceGara = punteggi.CodiceGara "
SQL = SQL & "GROUP BY punteggi.codiceGiocatore, Gare.CodiceCampo "
SQL = SQL & "ORDER BY punteggi.codiceGiocatore "
Set contGare = Server.CreateObject("ADODB.Recordset")
contGare.open SQL,FigspConn,3,1
if not contGare.EOF then
while not contGare.EOF
if contgare("contacampo") => 2 then
SQL = "SELECT punteggi.codiceGiocatore, Max(punteggi.PuntiCO) AS MaxDiPuntiCO, Gare.CodiceCampo "
SQL = SQL & "FROM ["&percorsoserver&"].Gare INNER JOIN punteggi ON Gare.CodiceGara = punteggi.CodiceGara "
SQL = SQL & "WHERE punteggi.codicegiocatore = '"&contGare("codicegiocatore") &"' "
SQL = SQL & "AND gare.codicecampo = "& contGare("codicecampo") &" "
'SQL = SQL & "AND punteggi.PuntiCO <> 0 "
SQL = SQL & "GROUP BY punteggi.codiceGiocatore, Gare.CodiceCampo "
SQL = SQL & "ORDER BY punteggi.codicegiocatore ASC "
Set tGare = Server.CreateObject("ADODB.Recordset")
tGare.open SQL,FigspConn,3,1
sSql = ""
sSql = sSql & "update Punteggi set ScartoPunti = 'N' "
sSql = sSql & "where CodiceGiocatore='" & tGare("CodiceGiocatore") & "' "
sSql = sSql & "AND puntiCO = "&tGare("MaxDiPuntiCo")&" "
set rs=FigspConn.execute (sSql)
else
SQL = "SELECT punteggi.codiceGiocatore, punteggi.PuntiCO, Gare.CodiceCampo "
SQL = SQL & "FROM ["&percorsoserver&"].Gare INNER JOIN punteggi ON Gare.CodiceGara = punteggi.CodiceGara "
SQL = SQL & "WHERE punteggi.codicegiocatore = '"&contGare("codicegiocatore") &"' "
SQL = SQL & "AND gare.codicecampo = "& contGare("codicecampo") &" "
SQL = SQL & "AND punteggi.PuntiCO <> "&tGare("MaxDiPuntiCo")&" " (riga che da errore!!)
SQL = SQL & "ORDER BY punteggi.codicegiocatore ASC "
'Response.Write "seconda sql...: " & SQL & "<br>"
'Response.flush
Set tGare = Server.CreateObject("ADODB.Recordset")
tGare.open SQL,FigspConn,3,1
'response.write tGare("codicegiocatore") & " | "
'response.write tGare("MaxDiPuntiCO") & " | "
'response.write tGare("codicecampo") & " <br> "
'response.flush
sSql = ""
sSql = sSql & "update Punteggi set ScartoPunti = 'S' "
sSql = sSql & "where CodiceGiocatore='" & tGare("CodiceGiocatore") & "' "
sSql = sSql & "AND puntiCO = "&tGare("MaxDiPuntiCo")&" "
set rs=FigspConn.execute (sSql)
end if
contGare.MoveNext
wend
end if
solo che non capisco come fare l'else in caso contrario al punteggio massimo.
Perché può capitare che il numero di gare è 3 o 4 e quindi devo impostare scartopunti a N solo al punteggio massimo.