Allora proviamo a spiegare meglio.
Ho una tabella giocatori, dove ho vari campi e il primo (univoco) è codicegiocatore (è l'ID che facevo riferimento prima)
Attraverso una pagina inserisco dei risultati che poi vanno a finire in 2 altre tabelle, e fin qui tutto bene. Attraverso questa pagina mi faccio fare delle funzioni matematiche.
La prima:
codice:
SQL = "select Punteggi.CodiceGiocatore, punteggi.girifatti, punteggi.colpi from Punteggi "
SQL = SQL & "where CodiceGara = " & Request.QueryString("Cod")
SQL = SQL & " and CodiceGiocatore = CodiceGiocatore "
Set scostam = Server.CreateObject("ADODB.Recordset")
scostam.open SQL,Conn,3,1
if not scostam.EOF then
while not scostam.EOF
totg = scostam("girifatti")
If totg > 0 then
If sspecialita = 1 OR sspecialita = 2 OR sspecialita = 3 Then
if totg = 3 Then
campopar = cint(spar * totg)
else
campopar = spar * totg
end if
end if
If sspecialita = 0 Then
if totg = 2 Then
campopar = cint(spar * totg)
end if
if totg = 4 Then
campopar = spar * totg
end if
End if
diff = Scostam("colpi") - campopar
scostamento = diff / totg
scostamento = formatnumber((scostamento),2)
scostamento = replace(scostamento, ",", ".")
Else
scostamento = -36
End If
SQL= ""
SQL = SQL & "update punteggi set "
SQL = SQL & " scost = " & scostamento
SQL = SQL & " where CodiceGara = " & Request.QueryString("Cod")
SQL = SQL & " and CodiceGiocatore = '" & Scostam("CodiceGiocatore") & "'"
'Response.Write "prima sql...: " & SQL & "
"
'Response.flush
set rs=Conn.execute (SQL)
If sTipogara = "C" Then
SQLC= ""
SQLC = SQLC & "update punteggiC set "
SQLC = SQLC & " scost = " & scostamento
SQLC = SQLC & " where CodiceGara = " & Request.QueryString("Cod")
SQLC = SQLC & " and CodiceGiocatore = '" & Scostam("CodiceGiocatore") & "'"
'Response.Write "prima sql...: " & SQL & "
"
'Response.flush
set rs=Conn.execute (SQLC)
End If
Scostam.MoveNext
wend
end if
E fin qui funziona tutto.
Poi sempre la stessa pagina esegue un'altra funzione:
codice:
SQL = "select tabellapar.*, Punteggi.*, Giocatori.NomeGiocatore, Giocatori.Sesso from giocatori INNER JOIN (tabellapar RIGHT JOIN punteggi ON tabellapar.scost = punteggi.scost) ON Giocatori.CodiceGiocatore = Punteggi.CodiceGiocatore WHERE CodiceGara = " & Request.QueryString("Cod") & ""
'Response.Write "terza sql...: " & SQL & "
"
'Response.flush
Set par = Server.CreateObject("ADODB.Recordset")
par.open SQL,Conn,3,1
if not par.EOF then
while not par.EOF
if sSpecialita = 1 AND sPar >= 33 Then
if par("punteggi.scost") >= -11 and par("punteggi.scost") <= 18 then
Spunti = par("minigolf") + 1
Spuntisoc = par("minigolf")
Snome = par("nomegiocatore")
sPunti = Replace(sPunti, ",", ".")
sPuntisoc = Replace(sPuntisoc, ",", ".")
'Response.Write "giocatore: " & snome & " sPunti...: " & sPunti & "
"
'Response.flush
else
sPunti = 0
Spuntisoc = 0
End if
SQL2 = ""
SQL2 = SQL2 & "update punteggi set punteggio = " & Spunti
SQL2 = SQL2 & ", punteggiosocieta = " & Spuntisoc
SQL2 = SQL2 & " where CodiceGiocatore = '" & par("CodiceGiocatore")
SQL2 = SQL2 & "' and CodiceGara = " & Request.QueryString("Cod")
'Response.Write "quarta sql...: " & SQL2 & "
"
'Response.flush
set rs=Conn.execute (SQL2)
If sTipogara = "C" Then
SQL2C = ""
SQL2C = SQL2C & "update punteggiC set punteggioC = " & Spunti
SQL2C = SQL2C & " where CodiceGiocatore = '" & par("CodiceGiocatore")
SQL2C = SQL2C & "' and CodiceGara = " & Request.QueryString("Cod")
'Response.Write "quarta sql...: " & SQL2 & "
"
'Response.flush
set rs=Conn.execute (SQL2C)
End If
End if
ed è in questo pezzo di codice che il programma non sempre funziona perchè inserisce "sPunti" = 0 anche quando "par("punteggi.scost")2 si trova tra -11 e 18.
tra le varie prove sono riuscito a capire che cambiando il codicegiocatore di quei pochi giocatori che non funzionano il programma funziona regolarmente.
Spero di essermi spiegato alla meglio.
Grazie