Visualizzazione dei risultati da 1 a 4 su 4

Discussione: Mi da errore perche?

  1. #1

    Mi da errore perche?

    Salve a tutti sapreste dirmi perchè da questo script crato per immettere dati in un database da form, sotto ricevo questo errore appena premo il tasto Submit
    Compilation Error
    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

    Compiler Error Message: BC30451: Name 'item' is not declared.

    Source Error:
    Line 9: strSql=""
    Line 10:
    Line 11: for each item in request.form
    Line 12: if item<>"Submit" then
    Line 13: strQuery= strQuery & item &","

    SCRIPT............................................ .......

    <%
    if request("id")=1 then
    on error resume next
    dim strQuery
    strQuery="INSERT INTO Utenti("
    dim strValori
    strValori=" VALUES("
    dim strSql
    strSql=""

    for each item in request.form
    if item<>"Submit" then
    strQuery= strQuery & item &","
    strValori= strValori & "'"&server.HTMLEncode(request.form(item))&"',"
    end if
    next

    strQuery=mid(strQuery,1,len(strQuery)-1) &")"
    strValori=mid(strValori,1,len(strValori)-1) &")"

    set rs =server.createObject("ADODB.Recordset")
    strConn="driver={Microsoft Access Driver (*.mdb)}; "
    strConn=strConn & " DBQ=" & Server.MapPath("d:\inetpub\wwwroot\fpdb\bedbportal e.mdb")
    strSql= strQuery & strValori
    rs.open strSql,strConn
    set rs=nothing
    if err.number<>0 then
    response.write err.number &"
    "&err.description
    else
    response.write "inserimento avvenuto con successo"
    end if

    response.end
    end if
    %>
    <form method="POST" action="script.asp?=1">
    <input type="text" name="U_FIRST" size="24">

    <input type="text" name="U_LAST" size="21">

    <input type="text" name="U_EMAIL" size="20">

    <input type="submit" name="Submit" value="Invia">
    </form>

  2. #2
    certo che se spiegavi cosa volevi fare magari uno ci capisce di +.

    cmq credo che ti dia errore quando cerchi di scorrere gli oggetti presenti nel form

    i .net cambia un pochino rispetto all'asp
    [code
    For Each item As Control In Me.FindControl("Form1").Controls
    If TypeOf (c) Is TextBox Then
    Dim txt As TextBox = CType(c, TextBox)
    if txt.Text <> "submit" then
    ....
    end if
    End If
    Next
    [/code]

    non so se può andare cmq provare no ncosta nulla.

    ciao

  3. #3

    Scusate

    susate hai ragione è per un form d'inserimento dati in un database

  4. #4
    cmq non c'è bisogno di fare un ciclo per leggere tutte le cose del form.


    puoi fare benissimo una cosa del genere

    INSERT INTO tb (campo1, campo2) VALUES ('" & text1.text & "', '" & text2.text & "')


Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.