Sto tentando di realizzare una procedura di tracking per un sito di trasporti, in cui l'utente cliccando all'interno di "checkBox" seleziona i campi data da aggiornare, dopo inserisce in un campo testo la data e tramite il click sul pulsante submit invia i valori ad un'altra pagina ASP che aggiorna una tabella di un database ACCESS.
Il problema sta nel fatto che l'istruszione update:
"UPDATE DATI SET dataBFine = #" & strDataTot & "# WHERE LECODI=" & strCod & " AND LERIFA IN (" & Replace(val(i), "'", "''") & ");"
Che in teoria dovrebbe aggiornare tutti i record selezionati, aggiorna solo il primo record.
Ho fatto un test in VB6 per aggiornare la tabella e tutto funziona bene, mentre in ASP aggiorna solo un record.
Dove potrebbe essere l'inghippo?
Allego lo script ASP che aggiorna il database.
<%@LANGUAGE="VBSCRIPT"%>
<%
Sub AggiornaDatabase(CampoAgg)
Set comm = Server.CreateObject("ADODB.Command")
comm.ActiveConnection = strConnessione
Select Case CampoAgg
Case "1" 'Data Consegna
If val(i) = 0 Then Exit Sub
strSql = "UPDATE DATI SET DataConsDest = #" & strDataTot & "# WHERE LECODI IN(" & strCod & " AND LERIFA IN (" & Replace(val(i), "'", "''") & ");"
Case "2" 'Data Giacenza
If val(i) = 0 Then Exit Sub
strSql = "UPDATE DATI SET DataGiacSosta = #" & strDataTot & "# WHERE LECODI=" & strCod & " AND LERIFA IN (" & Replace(val(i), "'", "''") & ");"
Case "3" 'Data Buon fine
If val(i) = 0 Then Exit Sub
strSql = "UPDATE DATI SET dataBFine = #" & strDataTot & "# WHERE LECODI=" & strCod & " AND LERIFA IN (" & Replace(val(i), "'", "''") & ");"
End Select
comm.CommandText = strSql
comm.CommandType = 1
comm.CommandTimeout = 0
comm.Prepared = True
comm.Execute
set comm=nothing
return
End Sub
%>
<%
blnNoProcedi=false
strDataConsId=""
strBFineId=""
strDataGiacId=""
strCod=Request.Cookies("Codice")("CodCli")
'strCod=Request.Form("Codice")
if (Request.Form("Data")<>"") then
strDataTot=Request.Form("Data")
end if
if not (IsDate(strDataTot)) then blnNoProcedi=true
if(Request.Form("DataGiac") <> "") then
strDataGiacId = Request.Form("DataGiac")
end if
if(Request.Form("DataCons") <> "") then
strDataConsId = Request.Form("DataCons")
end if
if(Request.Form("DataBFine") <> "") then
strBFineId = Request.Form("DataBFine")
end if
if (strDataConsId="" and strDataGiacId="" and strDataBFine="") then blnNoProcedi=true
if not blnNoProcedi then
if strDataConsId<>"" then
AggiornaDatabase "1"
end if
if strDataGiacId<>"" then
AggiornaDatabase "2"
end if
if strDataBFineId<>"" then
AggiornaDatabase "3"
end if
end if
%>
<html>
<head>
<title>Documento senza titolo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<%
if blnNoProcedi then
Response.Write "<h2><font face='Arial, Helvetica, sans-serif'>Controllare L'inserimento dei dati</font></h2>"
Response.Write("<form action='cognom.asp?Cod=" & strCod & " method='post' name='Form1' id='Form1'>")
Response.Write("<input type='submit' name='Submit' value='<--Indietro'>")
Response.Write("</form>")
Response.End()
'server.Transfer(cognom.asp)
else
Response.Write("<form action='cognom.asp?Cod=" & strCod & " method='post' name='Form1' id='Form1'>")
Response.Write("<input type='submit' name='Submit' value='<--Indietro'>")
Response.Write("</form>")
Response.End()
'server.Transfer(cognom.asp)
end if
%>
</p>
</body>
</html>
Spero che qualcuno mi aiuti
saluti


Rispondi quotando
