Ho un sito con diverse pagine con molti campi quindi avevo deciso per sbrigare le cose di usare ultradev per fare alcuni passaggi, quali insert, delate e update....
Per gli insert tutto ok...ora devo fare l'update di una pagina e non sò dove sbattere la testa mi dà un errore nella sintassi SQL ma non riesco a trovarlo...
aiuto !!!
l'errore è questo:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E09)
[TCX][MyODBC]You have an error in your SQL syntax near ' 1' at line 1
/cxp/fascicolo/agrofo1mod.asp, line 89
Mentre tutto il codice della pagina è questo:
---------------------------------------------
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="../Connections/Conn.asp" -->
<%
' *** Edit Operations: declare variables
MM_editAction = CStr(Request("URL"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Request.QueryString
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Update Record: set variables
If (CStr(Request("MM_update")) <> "" And CStr(Request("MM_recordId")) <> "") Then
MM_editConnection = MM_Conn_STRING
MM_editTable = "agro"
MM_editColumn = "id"
MM_recordId = "" + Request.Form("MM_recordId") + ""
MM_editRedirectUrl = "agrofo2mod.asp"
MM_fieldsStr = "riferimento|value|relagro|value|pippo12|value|relagrono|value|albeagro|value|adi|value|tali|value|buon|value|cond|value|albeagrono|value"
MM_columnsStr = "riferimento|',none,''|relagro|',none,''|pippo12|',none,''|relagrono|',none,''|albeagro|',none,''|adi|',none,''|tali|',none,''|buon|',none,''|cond|',none,''|albeagrono|',none,''"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")
' set the form values
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(i+1) = CStr(Request.Form(MM_fields(i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
End If
%>
<%
' *** Update Record: construct a sql update statement and execute it
If (CStr(Request("MM_update")) <> "" And CStr(Request("MM_recordId")) <> "") Then
' create the sql update statement
MM_editQuery = "update " & MM_editTable & " set "
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
FormVal = MM_fields(i+1)
MM_typeArray = Split(MM_columns(i+1),",")
Delim = MM_typeArray(0)
If (Delim = "none") Then Delim = ""
AltVal = MM_typeArray(1)
If (AltVal = "none") Then AltVal = ""
EmptyVal = MM_typeArray(2)
If (EmptyVal = "none") Then EmptyVal = ""
If (FormVal = "") Then
FormVal = EmptyVal
Else
If (AltVal <> "") Then
FormVal = AltVal
ElseIf (Delim = "'") Then ' escape quotes
FormVal = "'" & Replace(FormVal,"'","''") & "'"
Else
FormVal = Delim + FormVal + Delim
End If
End If
If (i <> LBound(MM_fields)) Then
MM_editQuery = MM_editQuery & ","
End If
MM_editQuery = MM_editQuery & MM_columns(i) & " = " & FormVal
Next
MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId
If (Not MM_abortEdit) Then
' execute the update
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%>
<%
Dim agro__MMColParam
agro__MMColParam = "1"
if (Request.QueryString("id") <> "") then agro__MMColParam = Request.QueryString("id")
%>
<%
set agro = Server.CreateObject("ADODB.Recordset")
agro.ActiveConnection = MM_Conn_STRING
agro.Source = "SELECT * FROM agro WHERE riferimento = " + Replace(agro__MMColParam, "'", "''") + ""
agro.CursorType = 0
agro.CursorLocation = 2
agro.LockType = 3
agro.Open()
agro_numRows = 0
%>
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "dsn=cxp"
set controllo = Server.CreateObject("ADODB.Recordset")
sql = "SELECT conagro FROM agro_due"
controllo.Open sql, Conn
if controllo.EOF then
else
if controllo.Fields.Item("conagro").Value="conclusa" then
response.redirect "modifica_block.htm"
end if
end if
controllo.close
set controllo = nothing
conn.close
set conn = nothing
%>
<%
Function IIF(ByVal expr,ByVal truepart,ByVal falsepart)
If expr Then
IIF=truepart
Else
IIF=falsepart
End If
End Function
Dim sRadio
'rs è il recordset......
sRadio = agro("relagro")
Dim sRadio10
'rs è il recordset......
sRadio1 = agro("albeagro")
Dim sRadio2
'rs è il recordset......
sRadio2 = agro("adi")
Dim sRadio3
'rs è il recordset......
sRadio3 = agro("tali")
Dim sRadio4
'rs è il recordset......
sRadio4 = agro("buon")
Dim sRadio5
'rs è il recordset......
sRadio5 = agro("cond")
%>
<html>
<head>
<title>Agroforestale 1</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table width="80%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<!--#include file="../Include/top_agrofo.asp" -->
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><font face="Arial, Helvetica, sans-serif" size="2"><b>Dati caratteristici</b></font></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>
<form ACTION="<%=MM_editAction%>" METHOD="POST" name="form1">
<table width="100%" border="0" cellspacing="0" cellpadding="2" bgcolor="33CC33">
<tr>
<td width="43%">
<p><b><font face="Arial, Helvetica, sans-serif" size="2">Riferimento
pratica n°
<input type="text" name="riferimento" readonly value="<%=Request.QueryString("id")%>">
</font></b></p>
<p><font size="2" face="Arial, Helvetica, sans-serif"><b><font color="0099cc">1-
Relazione agroforestale</font></b></font></p>
</td>
<td width="57%">
<div align="left"><b></b></div>
</td>
<tr>
<td colspan="2">
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td width="19%"> <font size="2" face="Arial, Helvetica, sans-serif">
<input type="radio" name="relagro" value="disponibile" <%=IIF(sRadio="disponibile","checked","")%>>
disponibile </font></td>
<td width="6%"><font size="2" face="Arial, Helvetica, sans-serif">data</font></td>
<td width="18%"> <font size="2" face="Arial, Helvetica, sans-serif">
<input type="text" name="pippo12" value="<%=agro("pippo12")%>">
</font></td>
<td width="17%"> <font size="2" face="Arial, Helvetica, sans-serif">
<input type="radio" name="relagro" value="non disponibile" <%=IIF(sRadio="non disponibile","checked","")%>>
non disponibile</font></td>
<td width="40%"> <font size="2" face="Arial, Helvetica, sans-serif">
<input type="radio" name="relagro" value="non necessaria" <%=IIF(sRadio="non necessaria","checked","")%>>
non necessaria</font></td>
</tr>
</table>
</td>
<tr>
<td colspan="2"><font face="Arial, Helvetica, sans-serif" size="2">Note:</font></td>
<tr>
<td colspan="2">
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td>
<textarea name="relagrono" cols="80"><%=agro("relagrono")%></textarea>
</td>
</tr>
</table>
</td>
<tr>
<td bgcolor="ffffcc" colspan="2"> </td>
<tr>
<td colspan="2"><font size="2" face="Arial, Helvetica, sans-serif"><b><font color="0099cc">2.
Alberi di alto fusto</font></b></font></td>
<tr>
<td colspan="2"><font size="2" face="Arial, Helvetica, sans-serif"><b>Si
evidenzia che:</b></font></td>
<tr>
<td colspan="2">
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td> <font size="2" face="Arial, Helvetica, sans-serif">
<input type="radio" name="albeagro" value="presenti" <%=IIF(sRadio10="presenti","checked","")%>>
presenti </font></td>
<td> <font size="2" face="Arial, Helvetica, sans-serif">
<input type="radio" name="albeagro" value="non presenti" <%=IIF(sRadio10="non presenti","checked","")%>>
non presenti</font></td>
</tr>
<tr>
<td> <font size="2" face="Arial, Helvetica, sans-serif">
<input type="radio" name="adi" value="adiacenti al fabbricato" <%=IIF(sRadio2="adiacenti al fabbricato","checked","")%>>
adiacenti al fabbricato</font></td>
<td> <font size="2" face="Arial, Helvetica, sans-serif">
<input type="radio" name="adi" value="non adiacenti" <%=IIF(sRadio2="non adiacenti","checked","")%>>
non adiacenti</font></td>
</tr>
<tr>
<td> <font size="2" face="Arial, Helvetica, sans-serif">
<input type="radio" name="tali" value="tali da compromettere la statica del fabbricato" <%=IIF(sRadio3="tali da compromettere la statica del fabbricato","checked","")%>>
tali da compromettere la statica del fabbricato</font></td>
<td> <font size="2" face="Arial, Helvetica, sans-serif">
<input type="radio" name="tali" value="tali da non compromettere la statica del fabbricato" <%=IIF(sRadio3="tali da non compromettere la statica del fabbricato","checked","")%>>
tali da non compromettere la statica del fabbricato</font></td>
</tr>
<tr>
<td> <font size="2" face="Arial, Helvetica, sans-serif">
<input type="radio" name="buon" value="in buone condizioni apparenti" <%=IIF(sRadio4="in buone condizioni apparenti","checked","")%>>
in buone condizioni apparenti</font></td>
<td> <font size="2" face="Arial, Helvetica, sans-serif">
<input type="radio" name="buon" value="in cattive condizioni apparenti" <%=IIF(sRadio4="in cattive condizioni apparenti","checked","")%>>
in cattive condizioni apparenti</font></td>
</tr>
<tr>
<td> <font size="2" face="Arial, Helvetica, sans-serif">
<input type="radio" name="cond" value="in condizioni statiche stabili" <%=IIF(sRadio5="in condizioni statiche stabili","checked","")%>>
in condizioni statiche stabili</font></td>
<td> <font size="2" face="Arial, Helvetica, sans-serif">
<input type="radio" name="cond" value="in condizioni statiche precarie" <%=IIF(sRadio5="in condizioni statiche precarie","checked","")%>>
in condizioni statiche precarie</font></td>
</tr>
</table>
</td>
<tr>
<td colspan="2"><font size="2" face="Arial, Helvetica, sans-serif">Note:</font></td>
<tr>
<td colspan="2">
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td>
<textarea name="albeagrono" cols="70"><%=agro("albeagrono")%></textarea>
</td>
</tr>
</table>
</td>
</table>
<br>
<center>
<input type="submit" name="Submit" value="Modifica / Avanti">
</center>
<input type="hidden" name="MM_recordId">
<input type="hidden" name="MM_update" value="true">
<input type="hidden" name="MM_recordId" value="<%= agro.Fields.Item("id").Value %>">
</form>
</td>
</tr>
</table>
</body>
</html>
<%
agro.Close()
%>
--------------------------------------------
Lo sò è un pò lunga ma era l'unico modo per farvela vedere !!!
Aspetto qualche notizia
Grazie
Matteo
------------------------------------
matteo@oldamerika.com
------------------------------------
ICQ N° 105837895
------------------------------------