Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it L'avatar di mdegiova
    Registrato dal
    Feb 2009
    residenza
    Sondrio
    Messaggi
    134

    Scrive I Dati Doppi Nel Mdb

    scusate non riesco a risolvere un problema, nella pagina di controllo nell'inserimento dei dati i un database access la seguente condizione mi raddoppia il dato inserito :

    ......
    <%
    if sub_1 = "no" and vani_1 = "no" then
    %>
    ......
    <%
    if sub_1 = "si" and vani_1 = "no" then
    %>
    ......
    <%
    if sub_1 = "no" and vani_1 = "si" then
    %>
    ......
    <%
    if sub_1 = "si" and vani_1 = "si" then
    %>
    .....

    ho capito che la condizione " and " non funziona correttamente poichè l'ASP comprende 2 condizioni come simile esempio SI NO e SI SI.

    dove sbaglio ?

  2. #2
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Fatti stampare le due variabile e verifica effettivamente cosa valgono.

    Roby

  3. #3
    Utente di HTML.it L'avatar di mdegiova
    Registrato dal
    Feb 2009
    residenza
    Sondrio
    Messaggi
    134
    Fanno riferimento nel form della pagina di inserimento :

    type="radio" name="sub" value="no"
    type="radio" name="sub" value="si"


    il codice completo nella oagina ASP di controllo è il seguente :

    <% LANGUACE="VBSCRIPT" %>
    <%

    On Error Resume Next

    id_1 = Request("id")
    tipo_1 = Request("tipo")
    sezione_1 = Request("sezione")
    foglio_1 = Request("foglio")
    mappale_1 = Request("mappale")
    sub_1 = Request("sub")
    vani_1 = Request("vani")
    n_sub_1 = Request("n_sub")
    n_vani_1 = Request("n_vani")
    rendita_1 = Request("rendita")
    salva_1 = Request("salva")


    Set conn = Server.CreateObject("ADODB.Connection")
    conn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & server.MapPath("P_EDILIZIE.mdb")

    %>
    <%
    if salva_1 = "SALVA" then
    %>
    <%
    if sub_1 = "no" and vani_1 = "no" then
    %>
    <%
    If id_1 = "" or tipo_1 = "" or sezione_1 = "" or foglio_1 = "" or mappale_1 = "" or rendita_1 = "" or sub_1 = "" or vani_1 = "" then

    conn.Execute(SQL)
    response.Redirect "2D.asp?errore=1&id_2="&id_1&"&tipo_2="&tipo_1&"&s ezione_2="&sezione_1&"&foglio_2="&foglio_1&"&mappa le_2="&mappale_1&"&rendita_2="&rendita_1&""
    conn.close
    set conn = nothing

    else

    SQL = "insert into CATASTO (id, tipo, sezione, foglio, mappale, sub, n_sub, vani, n_vani, rendita) values ('"&id_1&"', '"&tipo_1&"', '"&sezione_1&"', '"&foglio_1&"', '"&mappale_1&"', '"&sub_1&"', '0', '"&vani_1&"', '0', '"&rendita_1&"')"
    Set RS = Conn.Execute(SQL)

    conn.Execute(SQL)
    response.Redirect "2D.asp?id_2="&id_1&""
    conn.close
    set conn = nothing
    end if
    %>
    <%
    end if
    %>
    <%
    if sub_1 = "si" and vani_1 = "no" then
    %>
    <%
    if id_1 = "" or tipo_1 = "" or sezione_1 = "" or foglio_1 = "" or mappale_1 = "" or rendita_1 = "" or sub_1 = "" or vani_1 = "" then

    conn.Execute(SQL)
    response.Redirect "2D.asp?errore=1&id_2="&id_1&"&tipo_2="&tipo_1&"&s ezione_2="&sezione_1&"&foglio_2="&foglio_1&"&mappa le_2="&mappale_1&"&rendita_2="&rendita_1&"&n_sub_2 ="&n_sub_1&""
    conn.close
    set conn = nothing

    else

    SQL = "insert into CATASTO (id, tipo, sezione, foglio, mappale, sub, n_sub, vani, n_vani, rendita) values ('"&id_1&"', '"&tipo_1&"', '"&sezione_1&"', '"&foglio_1&"', '"&mappale_1&"', '"&sub_1&"', '"&n_sub_1&"', '"&vani_1&"', '0', '"&rendita_1&"')"
    Set RS = Conn.Execute(SQL)

    conn.Execute(SQL)
    response.Redirect "2D.asp?id_2="&id_1&""
    conn.close
    set conn = nothing
    end if
    %>
    <%
    end if
    %>
    <%
    if sub_1 = "no" and vani_1 = "si" then
    %>
    <%
    If id_1 = "" or tipo_1 = "" or sezione_1 = "" or foglio_1 = "" or mappale_1 = "" or rendita_1 = "" or sub_1 = "" or vani_1 = "" or n_vani_1 = "" then

    conn.Execute(SQL)
    response.Redirect "2D.asp?errore=1&id_2="&id_1&"&tipo_2="&tipo_1&"&s ezione_2="&sezione_1&"&foglio_2="&foglio_1&"&mappa le_2="&mappale_1&"&rendita_2="&rendita_1&"&n_vani_ 2="&n_vani_1&""
    conn.close
    set conn = nothing

    else

    SQL = "insert into CATASTO (id, tipo, sezione, foglio, mappale, sub, n_sub, vani, n_vani, rendita) values ('"&id_1&"', '"&tipo_1&"', '"&sezione_1&"', '"&foglio_1&"', '"&mappale_1&"', '"&sub_1&"', '0', '"&vani_1&"', '"&n_vani_1&"', '"&rendita_1&"')"
    Set RS = Conn.Execute(SQL)

    conn.Execute(SQL)
    response.Redirect "2D.asp?id_2="&id_1&""
    conn.close
    set conn = nothing
    end if
    %>
    <%
    end if
    %>
    <%
    if sub_1 = "si" and vani_1 = "si" then
    %>
    <%
    If id_1 = "" or tipo_1 = "" or sezione_1 = "" or foglio_1 = "" or mappale_1 = "" or rendita_1 = "" or sub_1 = "" or vani_1 = "" or n_sub_1 = "" or n_vani_1 = "" then

    conn.Execute(SQL)
    response.Redirect "2D.asp?errore=1&id_2="&id_1&"&tipo_2="&tipo_1&"&s ezione_2="&sezione_1&"&foglio_2="&foglio_1&"&mappa le_2="&mappale_1&"&rendita_2="&rendita_1&"&n_sub_2 ="&n_sub_1&"&n_vani_2="&n_vani_1&""
    conn.close
    set conn = nothing

    else

    SQL = "insert into CATASTO (id, tipo, sezione, foglio, mappale, sub, n_sub, vani, n_vani, rendita) values ('"&id_1&"', '"&tipo_1&"', '"&sezione_1&"', '"&foglio_1&"', '"&mappale_1&"', '"&sub_1&"', '"&n_sub_1&"', '"&vani_1&"', '"&n_vani_1&"', '"&rendita_1&"')"
    Set RS = Conn.Execute(SQL)

    conn.Execute(SQL)
    response.Redirect "2D.asp?id_2="&id_1&""
    conn.close
    set conn = nothing
    end if
    %>
    <%
    end if
    %>

  4. #4
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Nell'IF

    conn.Execute(SQL)
    response.Redirect "2D.asp?

    questa conn.Execute(SQL) è da eliminare.

    Nell'ELSE
    in questo:
    SQL = "insert into CATASTO (id, tipo, sezione, foglio, mappale, sub, n_sub, vani, n_vani, rendita) values ('"&id_1&"', '"&tipo_1&"', '"&sezione_1&"', '"&foglio_1&"', '"&mappale_1&"', '"&sub_1&"', '"&n_sub_1&"', '"&vani_1&"', '0', '"&rendita_1&"')"
    Set RS = Conn.Execute(SQL)
    conn.Execute(SQL)

    devi togleire Set RS = Conn.Execute(SQL)

    Roby

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.