Visualizzazione dei risultati da 1 a 6 su 6

Discussione: apici nell'insert

  1. #1
    Utente di HTML.it
    Registrato dal
    May 2006
    Messaggi
    172

    apici nell'insert

    Salve mi sono accorto che quando vado ad inserire delle parole con gli apici mi da errore(esempio l'input o citta') questo è il codi dell'inserti ...mi date una mano:
    <html>
    <head>


    <title>INSERIMENTO DATI</title>
    <LINK rel="stylesheet" href="Ticket.css" type="text/css">

    </head>
    <body>
    <%
    'on error resume next
    dim objconn
    dim objrs
    dim appo
    Campi_OK=true
    Msg=""
    %>
    <body topmargin="0" bgcolor="#0000ff" background="lgrey069.jpg">
    <table width="100%" border="0">


    </table>
    <table width="25%" border="0" heigt="300" align="center" >
    <tr align="center">





    <%
    If request.form("sistema") = "" then
    campi_OK=false
    Msg=Msg & "
    1. <span style=font-family:arial;font-size:12px;>Sistema</span>
    "
    end if

    If request.form("Presenza_Anagrafica_Cliente_Storica" ) = "" then
    campi_OK=false
    Msg=Msg & "
    1. <span style=font-family:arial;font-size:12px;>Presenza Anagrafica Cliente Storica</font></span>
    "
    end if

    If request.form("PeriodoRetentionLOGOnLlineMesi") = "" then
    campi_OK=false
    Msg=Msg & "
    1. <span style=font-family:arial;font-size:12px;>Periodo Retention LOG OnLine Mesi</font></span>
    "
    end if

    If request.form("PeriodoRetentionBackUPDeLOgMesi") = "" then
    campi_OK=false
    Msg=Msg & "
    1. <span style=font-family:arial;font-size:12px;>Periodo Retention BackUP De LOg Mesi</span>
    "
    end if

    If request.form("TracciamentoAccessoUtentiSistema") = "" then
    campi_OK=false
    Msg=Msg & "
    1. <span style=font-family:arial;font-size:12px;>Tracciamento Accesso Utenti Sistema </span>
    "
    end if

    If request.form("TracciamentoAccessoVisualizzazioneSt ampaAnagrafica") = "" then
    campi_OK=false
    Msg=Msg &"
    1. <span style=font-family:arial;font-size:12px;>Tracciamento Accesso Visualizzazione Stampa Anagrafica </span>
    "
    end if


    If Campi_OK = false then

    response.write "<span style=font-family:arial;font-size:18px;>I campi con l'asterisco sono obbligatori:</span>
    "
    response.write Msg
    %>
    </table>
    <p align="center"><input type="image" src="precedente.gif" onclick="history.back()"></p>

    <%
    else


    set objconn = Server.CreateObject("ADODB.Connection")
    set objrs = Server.CreateObject("ADODB.Recordset")
    objconn.Open("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = c:/mdb/Gestione_PI_Tickets.mdb")
    SQL = "INSERT INTO T_anagrafica"
    SQL = SQL & " ("
    SQL = SQL & "sistema,"
    SQL = SQL & "note_anag,"
    SQL = SQL & "SM_riferimento_nuovo,"
    SQL = SQL & "Presenza_Anagrafica_Cliente_Storica,"
    SQL = SQL & "PeriodoRetentionLOGOnLlineMesi,"
    SQL = SQL & "PeriodoRetentionBackUPDeLOgMesi,"
    SQL = SQL & "TracciamentoAccessoUtentiSistema,"
    SQL = SQL & "TracciamentoAccessoVisualizzazioneStampaAnagrafic a,"
    SQL = SQL & "Referenti,"
    SQL = SQL & "Descrizione,"
    SQL = SQL & "Interfaccia_utenti,"
    SQL = SQL & "Tipologia_cliente"

    SQL = SQL & ") "
    SQL = SQL & "VALUES "
    SQL = SQL & " ("
    SQL = SQL & "'" & Request.form("sistema") & "',"
    SQL = SQL & "'" & Request.form("note_anag") & "',"
    SQL = SQL & "'" & Request.form("SM_riferimento_nuovo") & "',"
    SQL = SQL & "'" & Request.form("Presenza_Anagrafica_Cliente_Storica" ) & "',"
    SQL = SQL & "'" & Request.form("PeriodoRetentionLOGOnLlineMesi") & "',"
    SQL = SQL & "'" & Request.form("PeriodoRetentionBackUPDeLOgMesi") & "',"
    SQL = SQL & "'" & Request.form("TracciamentoAccessoVisualizzazioneSt ampaAnagrafica") & "',"
    SQL = SQL & "'" & Request.form("TracciamentoAccessoUtentiSistema") & "',"
    SQL = SQL & "'" & Request.form("Referenti") & "',"
    SQL = SQL & "'" & Request.form("Descrizione")& "',"
    SQL = SQL & "'" & Request.form("Interfaccia_utenti") & "',"
    SQL = SQL & "'" & Request.form("Tipologia_cliente") & "'"
    SQL = SQL & ") "
    'response.write(SQL)
    objrs.Open SQL, objconn,1,3

    %>


    <body topmargin="0" bgcolor="#0000ff" background="lgrey069.jpg">
    <table width="30%" border="0" align="right">
    <tr
    <td align=right>
    <td>[b]<%Response.write("<p align='center'>L'Utente collegato è:" & Session("User") & "</p>")%>
    </tr>
    </table>

    <BODY leftmargin="0" bottommargin="10" rightmargin="0">
    <form method="POST" action="inserisci_anagrafica.asp">
    </table>
    <table width="100%" border="0">
    <tr align="left">
    <td>[img]clip_image002.gif[/img]</td>
    </tr>
    </table>
    <table width="12%" border="0">
    <tr align="left">
    <th>MD/BS-AO</th>
    </tr>
    </table>
    <table width="99%" border="0" bgcolor="red">
    <tr align="center">
    <th></th>

    </tr>
    </table>












    </tr>
    </td>
    </table>








    </table>
    <table width="25%" border="0" heigt="300" align="center" >
    <tr>
    <td align=center>
    <%
    Response.Write("Torna alla maschera d'inserimento")
    %>
    </tr>
    </td>
    </table>





    </table>
    <table width="25%" border="0" heigt="300" align="center" >
    <tr>
    <td align=center>
    TORNA AL MENU

    </tr>
    </td>
    </table>




    <table width="25%" border="0" heigt="300" align="center" >
    <tr>
    <td align=center>


    <%

    objconn.close
    Set objrs =Nothing
    Set objconn =Nothing
    end if
    %>
    </tr>
    </td>
    <table width="25%" border="0" heigt="300" align="center" >
    </table>
    </body>
    </html>
    grazue

  2. #2
    una ricerchina sul forum?

    cmq quando usi campi di form devi fare

    codice:
    "... values ('" & replace(variaile, "'","''") & "')"
    in pratica fai (te lo dico a parole: sostituisci a variabile, apice singolo, due apici


  3. #3
    Utente di HTML.it
    Registrato dal
    May 2006
    Messaggi
    172

    apici insert

    scusami ho pravato ma mi da un sacco di errori di chiusura, ma potresti farmi un esempio con il mi codice con almeno i primi due campi...ti ringrazio

  4. #4
    codice:
    SQL = SQL & "'" & replace(Request.form("SM_riferimento_nuovo"),"'","''") & "',"
    SQL = SQL & "'" & replace(Request.form("Presenza_Anagrafica_Cliente_Storica"),"'","''") & "',"

  5. #5
    Utente di HTML.it
    Registrato dal
    May 2006
    Messaggi
    172
    scusamio di nuovo non mi chiamare scocciante ma ho fatto come mi hai detto ma mi da ancora errore...questo è il codice modificato..l'errore mi dice prevista fine istruzione linea 98 cioè al primo campo(sistema)
    set objconn = Server.CreateObject("ADODB.Connection")
    set objrs = Server.CreateObject("ADODB.Recordset")
    objconn.Open("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = c:/mdb/Gestione_PI_Tickets.mdb")
    SQL = "INSERT INTO T_anagrafica"
    SQL = SQL & " ("
    SQL = SQL & "sistema,"
    SQL = SQL & "note_anag,"
    SQL = SQL & "SM_riferimento_nuovo,"
    SQL = SQL & "Presenza_Anagrafica_Cliente_Storica,"
    SQL = SQL & "PeriodoRetentionLOGOnLlineMesi,"
    SQL = SQL & "PeriodoRetentionBackUPDeLOgMesi,"
    SQL = SQL & "TracciamentoAccessoUtentiSistema,"
    SQL = SQL & "TracciamentoAccessoVisualizzazioneStampaAnagrafic a,"
    SQL = SQL & "Referenti,"
    SQL = SQL & "Descrizione,"
    SQL = SQL & "Interfaccia_utenti,"
    SQL = SQL & "Tipologia_cliente"

    SQL = SQL & ") "
    SQL = SQL & "VALUES "
    SQL = SQL & " ("
    SQL = SQL & "'" & Request.form("sistema"),"'","''") & "',"
    SQL = SQL & "'" & Request.form("note_anag") ,"'","''") & "',"
    SQL = SQL & "'" & replace(Request.form("SM_riferimento_nuovo"),"'"," ''") & "',"
    SQL = SQL & "'" & replace(Request.form("Presenza_Anagrafica_Cliente_ Storica"),"'","''") & "',"
    'SQL = SQL & "'" & Request.form("SM_riferimento_nuovo") ,"'","''") & "',"
    'SQL = SQL & "'" & Request.form("Presenza_Anagrafica_Cliente_Storica" ) ,"'","''") & "',"
    SQL = SQL & "'" & Request.form("PeriodoRetentionLOGOnLlineMesi"),"'" ,"''") & "',"
    SQL = SQL & "'" & Request.form("PeriodoRetentionBackUPDeLOgMesi"),"' ","''") & "',"
    SQL = SQL & "'" & Request.form("TracciamentoAccessoVisualizzazioneSt ampaAnagrafica") ,"'","''") & "',"
    SQL = SQL & "'" & Request.form("TracciamentoAccessoUtentiSistema") ,"'","''") & "',"
    SQL = SQL & "'" & Request.form("Referenti"),"'","''") & "',"
    SQL = SQL & "'" & Request.form("Descrizione"),"'","''") & "',"
    SQL = SQL & "'" & Request.form("Interfaccia_utenti"),"'","''") & "',"
    SQL = SQL & "'" & Request.form("Tipologia_cliente") ,"'","''") & "',"
    SQL = SQL & ") "
    'response.write(SQL)
    objrs.Open SQL, objconn,1,3

    %>

  6. #6
    manca replace( a tutti i campi che non ho scritto io

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.