Salve a tutti e Auguri per le feste.
Come regalo di Natale, vi chiedo di aiutarmi.
Il problema è questo: devo realizzare un form che aggiorni tutti i record in un DB MySql 5.0
In ASP ho realizzato un form che pesca i dati da una sub e usando
codice:
<%
' Pagina config_MOD_aggiorna_prezzi.asp
'INIZIO IMPOSTAZIONI ******************
Dim objConn, elencoCampiOutPut, v, vx, connString, conta
session.LCID = 1040
sub elencoCampiPrezzo(objConn, byRef elencoCampiOutPut)
Dim RsCampi, rsconta
sql = "SELECT * FROM Prodotti "
set rs = server.createObject("ADODB.Recordset")
rs.open sql, objConn
if not rs.eof then
v = 0 'Contatore record
ReDIM elencocampiOutPut ((((Rs.RecordCount )) -1),5)
do while not rs.eof
elencoCampiOutPut(v,0) = rs("id")
elencoCampiOutPut(v,1) = rs("codice")
elencoCampiOutPut(v,2) = rs("CPrezzo")
elencoCampiOutPut(v,3) = rs("RPrezzo")
elencoCampiOutPut(v,4) = rs("Prodotto")
'elencoCampiOutPut(v,5) = rs("IDProdotto")
' campo cancellato
elencoCampiOutPut(v,5) = rs("Cancellato")
v = v + 1
rs.moveNext
loop
end if
rs.close
set rs = nothing
end sub
dim myId
sub aggiornaPrezzi(objConn)
strSQL = "UPDATE prodotti SET CPrezzo = "& myCPrezzo &" , Rprezzo = "& myRprezzo &" , Cancellato = "& MyCancellato &" WHERE id=" & myID
objConn.Execute(strSQL)
end sub
il problema è sul RECORDCOUNT che manda il tutto in timeOut.
Ho provato a realizzare un sub ed eliminare il recordCount, mettendoci al suo posto
la variabile CONTA
codice:
Sub ContaRS(objConn, ByRef Conta)
set rs = conn.Execute("SELECT COUNT(*) AS tabella FROM Prodotti ")
conta = (rs("tabella"))
end sub
ma nulla di fatto.
La variabile non viene passata.
Come posso fare??
Pagina Modifica
codice:
<%
call dbConnect(conn,StrConnect)
set rs = conn.Execute("SELECT COUNT(*) AS tabella FROM Prodotti ")
'
conta = (rs("tabella"))
call elencoCampiPrezzo(conn,elencoCampiOutPut)
call elencoCampiPrezzoCor(conn,elencoCampiOutPut)
call dbDisconnect(conn)
%>
<table style="width:100%;" cellspacing="0" cellpadding="5">
<tr>
<td>
<p style="font-family:verdana;font-size:12 px;">Modulo per la modifica dei prezzi.
Per riattivare un prodotto che risulta eliminato, togliere la spunta.</p>
<%if UBound(elencoCampiOutPut) > -1 then%>
<form method="post" action="/hotel/shop2007/admin/edit_MOD_aggiorna_prezzi.asp">
<table width="100%" cellpadding="0" cellspacing="3">
<tr align="center" bgcolor="#FFFFCC" class="sm">
<td width="7%" height="10">Nr.</td>
<td width="19%" height="10">Codice</td>
<td width="39%" height="10">Prodotto nome </td>
<td width="14%" height="10">CPrezzo </td>
<td width="14%" height="10">RPrezzo </td>
<td width="7%" height="10">Attivo
si/no</td>
</tr>
<%for vx = 0 to UBound(elencoCampiOutPut)
Response.Write ("<input type=""text"" name=""id"& CStr(vx) &""" value="""& elencoCampiOutPut(vx,0) &""" />")%>
<%
Dim Cancellato , Tab, Tab1
cancellato = elencoCampiOutPut(vx,5)
%>
<tr class="<%
v = v + 1
If v Mod 2 = 1 Then
Response.Write "Tab4"
Else
response.Write "Tab3"
End If
%>">
<td>idNR.<%=elencoCampiOutPut(vx,0)%> (<%'=CStr(vx)+1%> <%'= tab%>)</td>
<td><%=elencoCampiOutPut(vx,1)%></td>
<td><%=elencoCampiOutPut(vx,4)%>
<%
Response.Write(Mid(elencoCampiOutPut(vx,4), 1, 200) & "...")
%> - <%=conta%></td>
<td><input type="text" name="CPrezzo<%=CStr(vx)%>" value="<%=VisualizzaPrezzo(elencoCampiOutPut(vx,2))%>" size="5" style="text-align:right;font-family:verdana;font-size:12 px;" />
<input type="hidden" name="idprodotto<%=CStr(vx)%>" value="<%=elencoCampiOutPut(vx,5)%>" size="5"/> </td>
<td>
<input type="text" name="RPrezzo<%=CStr(vx)%>" value="<%=VisualizzaPrezzo(elencoCampiOutPut(vx,3))%>" size="5" style="text-align:right;font-family:verdana;font-size:12 px;" />
<%'= cancellato %>
<%%></td>
<td>
<input type="checkbox" name="Cancellato<%=CStr(vx)%>" <% If cancellato = 1 Then response.Write("checked")%> value="1" /></td>
</tr>
<%next
Response.Write ("<input type=""TEXT"" name=""tot_prezzi"" value="""& vx-1 &""" />")%>
<tr>
<td colspan="6">
<div align="center">
<input type="submit" name="submit" value="Aggiorna i Prezzi" />
</div></td>
</tr>
</table>
</form>
<%else%>
nessun record trovato
<%end if%> </td>
</tr>
</table>
</td>
</tr>
</table>
codice:
'Pagina EDIT
<%
call dbConnect(conn, StrConnect)
tot_prezzi = Request.Form("tot_prezzi")
For i = 0 to tot_prezzi
myVar = "id"& CStr(i)
myID = Request.Form(myVar)
myVar2 = "CPrezzo"& CStr(i)
MyVar3 = "Rprezzo"& CStr(i)
MyVar5 = "IdProdotto" & Cstr(i)
MyVar6 = "cancellato" &Cstr(i)
MyCPrezzo = Request.Form(myVar2)
MyRprezzo = Request.Form(myVar3)
MyIDProdotto = Request.Form (myVar5)
MyCancellato = Request.Form(MyVar6)
MyIDProdotto = MyIdProdotto
MyRPrezzo = FormattaPrezzoPerDB(MyRPrezzo)
MyCPrezzo = FormattaPrezzoPerDB(MyCPRezzo)
MyIDCorrelato = Request.QueryString("MyIDCorrelato")
'If MyCancellato <> "true" Then MyCancellato = "False"
'If MyCorrelato <> "true" Then MyCorrelato = "False"
'call ContaRS(conn)
'conta = rs.Fields("tabella")
call aggiornaPrezzi(conn)
call aggiornaPrezziCor(conn)
Next
call dbDisconnect(conn)
%>
<%
response.Redirect("modifica_tutti_prezzi.asp")%>