Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it L'avatar di Mizushi
    Registrato dal
    Aug 2005
    Messaggi
    1,125

    Controllo record che non controlla...

    Ciao, perchè questo codice che dovrebbe controllare l'esistenza di un valore nel db non funziona, nel senso che qualunque cosa cerco di registrare (esistente o no nella tabella) dice sempre che il record esiste ?
    codice:
    <%
    
    Session.LCID = 1040
    
    function pulisci(stringa)
       pulisci = replace(stringa, "'", "''")
    end function
    
    strCodiceInterno  = Request.Form("CodiceInterno")
    strDescrizioneProdotto = pulisci(Request.Form("DescrizioneProdotto"))
    strUM = Request.Form("UM")
    
    strsql = "SELECT * FROM TabellaIngredientiSingoli WHERE CodInt= " & strCodiceInterno & "  and Descrizione= " & strDescrizioneProdotto & "'"
    Set rs = Server.CreateObject("ADODB.Recordset")
    rs.open "TabellaIngredientiSingoli", objconn, 3, 3
    
    if NOT Rs.Eof and NOT Rs.Bof then 
    response.write "<font face='verdana' size='2' color='#FF0000'>Il valore " & strCodiceInterno  & " o il Valore " & strDescrizioneProdotto & " risultano già registrati </font>" 
    
    rs.close
    set rs = nothing
    
    else
    
    sql0 = "INSERT INTO TabellaIngredientiSingoli (CodInt, Descrizione, UM) values ('"&strCodiceInterno&"', '"&strDescrizioneProdotto&"', '"&strUM&"')"
    objCONN.execute (Sql0)
    
    %>
    <script language="javascript">
      alert("Registrazione eseguita correttamente.");
      window.location.href("default.asp");
    </script>
    <% end if  %>
    Dove sbaglio?

  2. #2
    Utente di HTML.it L'avatar di viki1967
    Registrato dal
    Feb 2003
    Messaggi
    1,757
    Fai così:

    codice:
    <%
    
    Session.LCID = 1040
    
    function pulisci(stringa)
       pulisci = replace(stringa, "'", "|")
    end function
    
    strCodiceInterno  = Request.Form("CodiceInterno")
    strDescrizioneProdotto = pulisci(Request.Form("DescrizioneProdotto"))
    strUM = Request.Form("UM")
    
    strsql = "SELECT * FROM TabellaIngredientiSingoli WHERE CodInt = '" & strCodiceInterno & "'  and Descrizione = '" & strDescrizioneProdotto & "' "
    Set rs = Server.CreateObject("ADODB.Recordset")
    rs.open strsql, objconn, 3, 3
    
    if not Rs.Eof and not Rs.Bof then
    
    %>
    <script language="javascript">
    
    function NumeroCasuale(Da,A) {
      return Math.floor((A-Da+1) * Math.random() +Da);
    }
    
      alert("Il Codice Interno: <%=strCodiceInterno%> o la Descrizione prodotto: <%=strDescrizioneProdotto%> risultano già registrati.\nRegistrazione non eseguita.");
      location.href="default.asp?nocache="+NumeroCasuale(1,99999);
    </script>
    <%
    
    rs.close
    set rs = nothing
    
    else
    
    sql0 = "INSERT INTO TabellaIngredientiSingoli (CodInt, Descrizione, UM) values ('"&strCodiceInterno&"', '"&strDescrizioneProdotto&"', '"&strUM&"')"
    objCONN.execute (Sql0)
    
    %>
    <script language="javascript">
    
    function NumeroCasuale(Da,A) {
      return Math.floor((A-Da+1) * Math.random() +Da);
    }
      alert("Registrazione eseguita correttamente.");
      location.href="default.asp?nocache="+NumeroCasuale(1,99999);
    
    </script>
    <% end if  %>
    A S P : tutto il resto è noia...
    L I N U X : forse mi "converto"...

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.