Ciao a tutti,
vorrei inserire dei dati in un database. Ho creato un form per l'inserimento dei dati, mi consente il controllo dei campi nel database (infatti se provo a inserire dati già presenti mi dice che sono già presenti) però non mi aggiunge il nuovo record e mi da questo errore:
(utilizzo un db Access)
Microsoft JET Database Engine (0x80004005)
Per l'operazione è necessaria una query aggiornabile.
Codice:
<%
If Request.Form("aggiungi") <> "" Then ' Quando premo il pulsante
Dim conn,a,b,tmp_zona,deca
set conn = server.createobject("adodb.connection")
conn.open("Provider=Microsoft.Jet.oledb.4.0;Data Source=D:\Ilg\mail.mdb")
set rs = server.createobject("adodb.recordset")
rs.activeconnection = conn
rs.source = "SELECT * FROM TMail"
rs.open
a = Request.Form("nome") ' Recupero i dati nel form
b = Request.Form("nome2")
if ((a="") or (b="")) or ((a="") and (b="")) then ' Se il form ha campi vuoti
response.Write("Compilare correttamente")
end if
if (a<>"") then
do while not rs.eof
tmp_zona=rs("zona")
if (a = tmp_zona) then
response.Write("già presente")
deca=10
end if
rs.movenext
loop
end if
conn.Close
Set conn = Nothing
if ((deca<>10) and (a<>"") and (b<>"")) then
set conn2 = server.createobject("adodb.connection")
conn2.open("Provider=Microsoft.Jet.oledb.4.0;Data Source=D:\Ilg\mail.mdb")
conn2.Execute("INSERT INTO TMail (zona, zona2) VALUES ('" & a & "','" & b & "')" )
'response.Redirect("inserito.asp")
end if
End If
%>
<html>
<body>
<form method="post">
<table width="200" border="0">
<tr>
<td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Zona</font></td>
<td><input type="text" name="nome"></td>
</tr>
<tr>
<td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Zona2</font></td>
<td><input type="text" name="nome2"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="aggiungi" value="Aggiungi"></td>
</tr>
</table>
</form>
</body>
</html>
Qualche consiglio?
Grazie

Rispondi quotando


