Type mismatch: 'LBound' - pure asp file upload - conflitto con db

Di: Alessandra73 | 26/09/2020 18:14:00
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'LBound'
/pannello.asp, line 156
Ciao a tutti, chiedo il vostro aiuto x adattare la soluzione fatta da Gian Paolo al mio codice. Purtroppo io non sono all'altezza di assemblare il codice giusto al mio.
Scritto da Gian Paolo da questo link
http://www.001design.it/forum_italiano/thread.php?id=1425
Non si tratta di conflitto... le impostazioni di default dell'estensione "Pure Asp Upload" e i parametri per l'inserimento dei record di Dreamweawer 7.1, non producono l'azione di upload immagine e aggiornamento del database allo stesso tempo. Mancano alcune istruzioni nel codice, che ho dovuto reperire altrove e inserire manualmente.
Il codice da inserire, per procurare l'azione "Inserisci record" è il seguente:
' *** 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 = ""
%>
<%
' *** Edit Operations: (Modified for File Upload) declare variables
MM_editAction = CStr(Request.ServerVariables("URL")) 'MM_editAction = CStr(Request("URL"))
If (UploadQueryString <> "") Then
MM_editAction = MM_editAction & "?" & UploadQueryString
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: (Modified for File Upload) set variables
If (CStr(UploadFormRequest("MM_insert")) <> "") Then
MM_editConnection = MM_upload_STRING
MM_editTable = "dati"
MM_editRedirectUrl = ""
MM_fieldsStr = "blob|value"
MM_columnsStr = "blob|',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(UploadFormRequest(MM_fields(i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And UploadQueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And UploadQueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & UploadQueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & UploadQueryString
End If
End If
End If
%>
<%
' *** Insert Record: (Modified for File Upload) construct a sql insert statement and execute it
If (CStr(UploadFormRequest("MM_insert")) <> "") Then
' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
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_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End if
MM_tableValues = MM_tableValues & MM_columns(i)
MM_dbValues = MM_dbValues & FormVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"
If (Not MM_abortEdit) Then
' execute the insert
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
%>
Text
Questo invece è il mio codice da mettere apposto a causa di quell'errore lBound
<%
' *** Edit Operations: (Modified for File Upload) declare variables
Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd
Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId
Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (UploadQueryString <> "") Then
MM_editAction = MM_editAction & "?" & UploadQueryString
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: (Modified for File Upload) set variables
If (CStr(UploadFormRequest("MM_insert")) = "form1") Then
MM_editConnection = MM_Conn_c_STRING
MM_editTable = "Tab_LaChiocciola"
MM_editRedirectUrl = "../Inserimento_Avvenuto.asp"
MM_fieldsStr = "TIPOLOGIA|value|TIPOdiOFFERTA|value|VANI|value|SUPERFICE|value|DESCRIZIONE|value|PREZZO|value|LOCALITA|value|CITTA|value|file|value"
MM_columnsStr = "TIPOLOGIA|', none,''|TIPOdiOFFERTA|',none,''|VANI|',none,''|SUPERFICE|',none,''|DESCRIZIONE|', none,''|PREZZO|',none,''|LOCALITA|',none,''|CITTA|',none,''|FOTO_ESTERNA|',none,''"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")
' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(UploadFormRequest(MM_fields(MM_i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And UploadQueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And UploadQueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & UploadQueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & UploadQueryString
End If
End If
End If
%>
<%
' *** Insert Record: (Modified for File Upload) construct a sql insert statement and execute it
Dim MM_tableValues
Dim MM_dbValues
If (CStr(UploadFormRequest("MM_insert")) <> "") Then
' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),",")
MM_delim = MM_typeArray(0)
If (MM_delim = "none") Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none") Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none") Then MM_emptyVal = ""
If (MM_formVal = "") Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "") Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'") Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End If
MM_tableValues = MM_tableValues & MM_columns(MM_i)
MM_dbValues = MM_dbValues & MM_formVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"
If (Not MM_abortEdit) Then
' execute the insert
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
%>
Grazie a tutti. Il brutto è che le immagini le carica nella cartella pubblic ma i dati no, purtroppo.

Risposte


RISOLTO

intanto ho provato a cambiare questa riga, l'ho trovato in rete, l'errore è cambiato. Sembra che chi l'ha cambiato ci sia riuscito,
dicevano
Le funzioni lbound e ubound servono per restituire l'indice inferiore e maggiore di un array, secondo me il problema e che non riconosce come array MM_fields.
Questa potrebbe essere la risoluzione del problema:
sostituisci:
If (CStr(UploadFormRequest("MM_insert")) = "form1") Then con
If (CStr(UploadFormRequest("MM_insert")) <> "") Then
così l'ho fatto e ora dice che il campo è troppo piccolo.
l'ho sostituita dove diceva
<%
' *** Insert Record: (Modified for File Upload) set variables
'If (CStr(UploadFormRequest("MM_insert")) = "form1") Then questa l'ho passata a commento
If (CStr(UploadFormRequest("MM_insert")) <> "") Then
MM_editConnection = MM_Conn_c_STRING
MM_editTable = "Tab_LaChiocciola"
MM_editRedirectUrl = "../Inserimento_Avvenuto.asp"
MM_fieldsStr = & quot;TIPOLOGIA|value|TIPOdiOFFERTA|value|VANI|value|SUPERFICE|value|DESCRIZIONE|
value|PREZZO|value|LOCALITA|value|CITTA|value|file|value"
MM_columnsStr = "TIPOLOGIA|',none,''|TIPOdiOFFERTA|',none,''|VANI|',none,''|SUPERFICE|',none,''|DESCRIZIONE|',none,''|PREZZO|',none,''|LOCALITA|',none,''|CITTA|',none,''|FOTO_ESTERNA|',none,''"

Di: Alessandra73 | 26/09/2020 18:14:00