Visualizzazione dei risultati da 1 a 4 su 4

Discussione: Problemi con delete

  1. #1

    Problemi con delete

    Salve a tutti ho un problema ad eliminare le foto con il seguente codice il record riesco ad eliminarlo .. potreste gentilmente aiutarmi .


    codice:
    <%
    
    id_annuncio = request("id_annuncio")
    
    
    Set objConn = Server.CreateObject("ADODB.Connection")
    strConn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("/public/db_db/mercatino.mdb") 
    objConn.Open strConn
       
    
    SQL= "SELECT foto FROM messaggi WHERE id_annuncio="&id_annuncio&""
    Set RS = Server.CreateObject("ADODB.Recordset")
    RS.Open SQL, objConn
    
    if not RS.eof then
    file_collegato = RS("foto")
    end if
    
    RS.close
    set RS = nothing
    
    
    path_file="/public/foto_annunci/"
    
    Set FileObject=CreateObject("Scripting.FileSystemObject")
    dir_file=Server.MapPath(path_file)
    if (FileObject.FileExists(dir_file & "/" & file_collegato)) then 
    FileObject.DeleteFile(dir_file & "/" & file_collegato)
    end if
    
    Set FileObject=Nothing
    
    
    SQL= "DELETE * FROM messaggi WHERE id_annuncio="&id_annuncio&""
    objConn.Execute SQL
    
    
    %>

  2. #2
    immagino che quando dici che non riesci ad "eliminare la foto" intendi "eliminare il file"...

    fatti stampare questo valore

    (dir_file & "/" & file_collegato)

    e controlla che sia giusto

  3. #3
    Ciao optime per la risposta posto il codice modificato e funzionante ..



    codice:
    <%
    
    id_annuncio = request("id_annuncio")
    
    
    Set objConn = Server.CreateObject("ADODB.Connection")
    strConn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("/public/db_db/mercatino.mdb") 
    objConn.Open strConn
       
    
    SQL= "SELECT foto FROM messaggi WHERE id_annuncio="&id_annuncio&""
    Set RS = Server.CreateObject("ADODB.Recordset")
    RS.Open SQL, objConn
    
    if not RS.eof then
    file_collegato = RS("foto")
    end if
    
    RS.close
    set RS = nothing
    
     
    
    Dim objFSO 
    Set objFSO = Server.CreateObject("Scripting.FileSystemObject") 
    
    percorso_completo = Server.MapPath("/public/foto_annunci/" & file_collegato) 
    
    objFSO.DeleteFile(percorso_completo) 
    
    Set objFSO = Nothing 
    
    SQL= "DELETE * FROM messaggi WHERE id_annuncio="&id_annuncio&""
    objConn.Execute SQL
    
    Response.Redirect("annunci.asp")
    
    %>

  4. #4

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.