Visualizzazione dei risultati da 1 a 5 su 5
  1. #1

    INSERT INTO a volte inserisce il spazi bianchi

    Ciao ragazzi ho questo codice
    codice:
    <%'Open the database
    dim news,studente,notiziatemp
    studente=Request.Form("studente")
    notiziatemp=Request.Form("notizia")
    notizia=Replace(notiziatemp, "'", "''" )
    news=cbool(Request.QueryString("ordina"))
    dim objConn, strCon, objRS, strSQL, ident
    if studente="tutti" then
    dim objConn2, strCon2, objRS2, strSQL2, ident2
    '******************             NEWS A TUTTI                    ******************************
    Set objConn2 = Server.CreateObject("ADODB.Connection")
    
    '*************************************
    ' CHANGE THE FOLLWING DATA SOURCE
    ' PATH TO POINT TO WHERE YOU HAVE
    '*************************************
    strCon2 = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("\mdb-database\studenti.mdb")
    objConn2.connectionstring = strCon2
    objConn2.Open
    Set objRS2 = Server.CreateObject("ADODB.Recordset")
    strSQL2 = "SELECT user FROM studenti"
    ' Open the Database
    objRS2.Open strSQL2, objConn2
    
    do while not objRS2.eof
    studente=objRS2("user")
    Set objConn = Server.CreateObject("ADODB.Connection")
    
    '*************************************
    ' CHANGE THE FOLLWING DATA SOURCE
    ' PATH TO POINT TO WHERE YOU HAVE
    '*************************************
    strCon = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("\mdb-database\studenti.mdb")
    objConn.connectionstring = strCon
    objConn.Open
    Set objRS = Server.CreateObject("ADODB.Recordset")
    
    ' Set the SQL Statement to get the information from the database 
    strSQL = "INSERT INTO  news(studente,notizia,attiva) VALUES ('" & studente & "','" & notizia & "'," & 1 & ") " 
    objConn.Execute(strSQL) 
    objConn.Close 
    set objConn = nothing
    objRS2.Movenext
    loop
    objConn2.Close
    '******************         FINE    NEWS A TUTTI                    ******************************  
    else
    '******************           NEWS SINGOLA                      ******************************  
    Set objConn = Server.CreateObject("ADODB.Connection")
    
    '*************************************
    ' CHANGE THE FOLLWING DATA SOURCE
    ' PATH TO POINT TO WHERE YOU HAVE
    '*************************************
    strCon = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("\mdb-database\studenti.mdb")
    objConn.connectionstring = strCon
    objConn.Open
    Set objRS = Server.CreateObject("ADODB.Recordset")
    
    ' Set the SQL Statement to get the information from the database 
    strSQL = "INSERT INTO  news(studente,notizia,attiva) VALUES ('" & studente & "','" & notizia & "'," & 1 & ") " 
    objConn.Execute(strSQL) 
    objConn.Close 
    set objConn = nothing
    end if
    '******************         FINE    NEWS SINGOLA                    ******************************  
    %>
    I dati vengono raccolti da una form nella pagina precedente
    e vengono inseriti in un DB
    se nella casella è del form si è selezionato tutti in automatico viene generato il messaggio per tutti gli user del db.
    il tutto sembra funzionare soltanto che a volte (a random)
    non viene inserito il contenuto della variabile notizia ma una stringa vuota.
    Cosa sbaglio?

  2. #2
    La stringa vuota viene inserita quando la pagina viene chiamata senza passarle alcun valore da inserire nel db.

  3. #3
    no, intendo che inserisce la stringa vuota se prima compilo il form,
    come se la request.form avvenisse dopo l'insert into (impossibile)
    Non è che mi sono trovate stringhe vuote, è proprio che anche compilando il form le inserisce blank

  4. #4
    E tutto in una pagina? Form e codice che inserisce i dati?

  5. #5
    il form è nella pagina precedente news.asp
    newsadd.asp invece fa l'insert into

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.