ciao a tutti,
ho abbastanza problemi a far funzionare questa pagina ASP:
codice:
<%@ LANGUAGE = VBScript %>
<% Option Explicit %>
<%
Dim Conn
Dim rs
Dim rs1
Dim strconn
Dim strsql
Dim i
Dim j
Dim nome
Dim a(10)
Dim b(10,10)
Dim num, mia
Dim ch
sub scrivi(conn,ch,b,n)
Dim strsql
Dim j
strsql= "UPDATE mov SET "
for j = 2 to rs.Fields.Count-2
if b(0,j) <> "*" then
strsql = strsql & rs.Fields(j).name & "= " & b(1,j) & ", "
end if
next
strsql= strsql & rs.Fields(count-1).name & "= " & b(1,count-1) & " WHERE mov.cont=" & ch
response.write strsql
conn.execute(strsql)
end sub
strconn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
strconn=strconn+Server.MapPath("db1.mdb")
Set conn=Server.CreateObject("ADODB.Connection")
Set rs=Server.CreateObject("ADODB.Recordset")
Set rs1=Server.CreateObject("ADODB.Recordset")
conn.Open strconn
nome = ("mov")
rs.open nome, conn
rs1.open "pdc", conn
for i=0 to rs.Fields.Count-1
a(i) = request.form(rs.Fields(i).Name)
select case rs.Fields(i).type
case 3
if a(i) ="" then a(i)=" is not null " else a(i)= " = " & a(i) end if
case 7
if a(i) ="" then a(i)=" is not null " else a(i)= " = #" & a(i) & "# " end if
case else
if a(i) ="" or a(i) ="----" then a(i)=" is not null " else a(i)= " = '" & a(i) & "' " end if
end select
next
strsql ="SELECT * FROM " & nome & " WHERE "
for i = 0 to rs.Fields.Count-2
strsql = strsql & rs.Fields(i).name & a(i) & " and "
next
i = rs.Fields.Count-1
strsql = strsql & rs.Fields(i).name & a(i)
'response.write strsql
Set rs = conn.execute(strsql)
%>
<HTML>
<HEAD><TITLE>Visualizzazone dei record</TITLE>
<link rel="stylesheet" type="text/css" href="iframe.css"></HEAD>
<BODY>
<font color=black>VISUALIZZA TABELLA:</font> <% = nome %>
<TABLE border=2 bordercolor=black valign=top border=1>
<TR>
<% For i=1 to rs.Fields.Count-1%>
<TD bgcolor=black><% =rs.Fields(i).Name %></TD>
<% Next %>
</TR>
<%
if rs.EOF then %>
</TABLE>
non esistono </p>
<% else
rs.MoveFirst
num=0
Do While Not rs.EOF %>
<TR>
<form method="post" name="MODIFICA" action="scrivi.asp">
<% For i=1 to rs.Fields.Count-1
if rs.Fields(i).Name="codice" then %>
<TD VALIGN=TOP>
<SELECT NAME="codice"><%=num%>
<%
rs1.Movefirst
Do While Not rs1.EOF
%>
<% if rs("codice")= rs1("codice") then %>
<OPTION Value="<%=rs1("codice")%>" selected><%=rs1("codice")%> - <%=rs1("denominazione")%></OPTION>
<% else %>
<OPTION Value="<%=rs1("codice")%>"><%=rs1("codice")%> - <%=rs1("denominazione")%></OPTION>
<% end if
rs1.Movenext
Loop %>
</SELECT>
</td>
<% else %>
<TD VALIGN=TOP><input type="text" size="<%=rs.Fields(i).definedsize%>"
NAME="<%=rs.Fields(i).Name%><%=cstr(num) %>" value ="<% =rs.Fields(i).Value %>"></TD>
<% end if
mia = rs.Fields(i).name & cstr(num)
if request.form(mia) <> rs.Fields(i).value then
b(1,i) = request.form(mia)
b(0,i) = i
else
b(0,i) = "*"
end if
'response.write mia
response.write request.form(mia)
Next
%>
<% ch=rs.Fields(0).Value %>
<td><input type="button" onclick="scrivi(conn,ch,b,num);" value="conferma<%=cstr(num)%>"></td>
</TR>
<% rs.MoveNext
num=num+1
Loop
%>
<input type="submit" name="fine" value="invia">
</form>
<%
End If
rs.Close
rs1.Close
conn.close
Set rs=nothing
Set conn=nothing
%>
</TABLE>
</BODY>
</HTML>
in particolare non funziona la sub con la query di update (probabilmente per un errore di sintassi che io non trovo perché il response.write dà una stringa esatta) e la request.form(mia) che è sicuramente sbagliata...
quello che cerco di fare è prendere i valori della form senza andare in una pagina successiva per fare più modifiche di diversi record in una volta sola e la request.form non funziona...
qualcuno sa se sia possibile fare una cosa del genere?
grazie