Visualizzazione dei risultati da 1 a 2 su 2

Discussione: cancella record

  1. #1

    cancella record

    Ciao,
    avrei bisogno di aiuto!
    Sto facendo un admin in ASP per un DBAccess contente immagini e descrizione; praticamente dopo aver caricato sul DB le immagini, si devono "creare" delle "schede_tecniche" (sempre in asp) prendendo le immagini dal DB e scrivendo i relativi testi.
    Inoltre ci deve essere la possibilità di cancellare queste schede_tecniche.
    Quanto riguarda il caricamento immagini nel DB tutto ok.
    Quanto riguarda l'inserimento nuove schede_tecniche nel DB tutto ok.
    La cancellazione mi sta creando problemi!!!

    Praticamente io faccio cercare da un elenco la scheda_tecnica da cancellare, cliccando su "cerca" mi compare il titolo della scheda_tecnica e cliccando su "cancella scheda" mi DOVREBBE cancellare la scheda e lasciarmi la possibilità di cliccare sul "cancella immagine" invece mi cancella la scheda ma non mi fa più vedere il link per cancellare la relativa immagine associata!!!
    Questa operazione non posso farla fare prima perchè se non mi cancella prima la scheda_tecnica non mi fa ovviamente cancellare l'immagine associata!!!

    Invio sotto la pagina con il codice!
    Potete aiutarmi a capire dove sbaglio!
    Grazie mille!!!
    (sono alle prime armi!)
    Alex


    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>


    <%

    Dim MM_editAction
    Dim MM_abortEdit
    Dim MM_editQuery
    Dim MM_editCmd

    Dim MM_editConnection
    Dim MM_editTable
    Dim MM_editRedirectUrl
    Dim MM_editColumn
    Dim MM_recordId

    Dim MM_fieldsStr
    Dim MM_columnsStr
    Dim MM_fields
    Dim MM_columns
    Dim MM_typeArray
    Dim MM_formVal
    Dim MM_delim
    Dim MM_altVal
    Dim MM_emptyVal
    Dim MM_i

    MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
    If (Request.QueryString <> "") Then
    MM_editAction = MM_editAction & "?" & Request.QueryString
    End If

    MM_abortEdit = false

    MM_editQuery = ""
    %>
    <%

    if (CStr(Request("MM_delete")) = "form2" And CStr(Request("MM_recordId")) <> "") Then

    MM_editConnection = MM_database_STRING
    MM_editTable = "scheda_tecnica"
    MM_editColumn = "id"
    MM_recordId = "" + Request.Form("MM_recordId") + ""
    MM_editRedirectUrl = "cancellarticolo.asp"

    If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
    If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
    MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
    Else
    MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
    End If
    End If

    End If
    %>
    <%

    If (CStr(Request("MM_delete")) <> "" And CStr(Request("MM_recordId")) <> "") Then

    MM_editQuery = "delete from " & MM_editTable & " where " & MM_editColumn & " = " & MM_recordId

    If (Not MM_abortEdit) Then
    Set MM_editCmd = Server.CreateObject("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_editConnection
    MM_editCmd.CommandText = MM_editQuery
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

    If (MM_editRedirectUrl <> "") Then
    Response.Redirect(MM_editRedirectUrl)
    End If
    End If

    End If
    %>
    <%
    Dim schede_tech
    Dim schede_tech_numRows

    Set schede_tech = Server.CreateObject("ADODB.Recordset")
    schede_tech.ActiveConnection = MM_database_STRING
    schede_tech.Source = "SELECT * FROM scheda_tecnica ORDER BY titolo ASC"
    schede_tech.CursorType = 0
    schede_tech.CursorLocation = 2
    schede_tech.LockType = 1
    schede_tech.Open()

    schede_tech_numRows = 0
    %>
    <%
    Dim del_scheda_tech__MMColParam
    del_scheda_tech__MMColParam = "1"
    If (Request.Form("id") <> "") Then
    del_scheda_tech__MMColParam = Request.Form("id")
    End If
    %>
    <%
    Dim del_scheda_tech
    Dim del_scheda_tech_numRows

    Set del_scheda_tech = Server.CreateObject("ADODB.Recordset")
    del_scheda_tech.ActiveConnection = MM_database_STRING
    del_scheda_tech.Source = "SELECT * FROM scheda_tecnica WHERE id = " + Replace(del_scheda_tech__MMColParam, "'", "''") + " ORDER BY titolo ASC"
    del_scheda_tech.CursorType = 0
    del_scheda_tech.CursorLocation = 2
    del_scheda_tech.LockType = 1
    del_scheda_tech.Open()

    del_scheda_tech_numRows = 0
    %>
    <%
    Dim Repeat1__numRows
    Dim Repeat1__index

    Repeat1__numRows = -1
    Repeat1__index = 0
    del_scheda_tech_numRows = del_scheda_tech_numRows + Repeat1__numRows
    %>
    <html>
    <head>
    <title>Cancella Articolo</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_reloadPage(init) { //reloads the window if Nav4 resized
    if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
    else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
    }
    MM_reloadPage(true);
    //-->
    </script>
    </head>
    <body leftmargin="0" topmargin="0">

    <form name="form1" method="post" action="">
    <div align="center"><table width="400" height="30" border="0" cellspacing="0" cellpadding="0">
    <tr><td width="400" height="30" class="testipic"><div align="center"><select name="id" id="id" class="testipic">
    <option class="testipic" value="1">Scheda articolo ...</option>
    <%
    While (NOT schede_tech.EOF)
    %>
    <option class="testipic" value="<%=(schede_tech.Fields.Item("id").Value)%>" ><%=(schede_tech.Fields.Item("titolo").Value)%></option>
    <%
    schede_tech.MoveNext()
    Wend
    If (schede_tech.CursorType > 0) Then
    schede_tech.MoveFirst
    Else
    schede_tech.Requery
    End If
    %>
    </select>
    <input type="submit" name="Submit" class="testipic" value="Cerca scheda articolo"></div></td></tr>
    </table></div></form>




    <%
    While ((Repeat1__numRows <> 0) AND (NOT del_scheda_tech.EOF))
    %>

    <form name="form2" method="POST" action="<%=MM_editAction%>">
    <div align="center"><table width="400" height="200" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="400" height="20" class="titoli">TITOLO:<font class="testi"><%=(del_scheda_tech.Fields.Item("tit olo").Value)%></font></td>
    </tr>
    <tr>
    <td width="400" height="20" class="titoli">Descrizione:<font class="testi"><%=(del_scheda_tech.Fields.Item("des crizione").Value)%></font></td>
    </tr>
    <tr>
    <td width="400" height="20" class="titoli">Caratteristiche:<font class="testi"><%=(del_scheda_tech.Fields.Item("car atteristiche").Value)%></font></td>
    </tr>
    <tr>
    <td width="400" height="50" class="testipic"><input class="testipic" type="submit" name="Submit2" value="Cancella scheda articolo"></td>
    </tr>
    <tr>
    <td width="400" height="20" class="testi1"> Ricordati di rimuovere anche
    le immagini inutilizzate!</td>
    </tr>
    <tr>
    <td width="400" height="40" class="menu"><a class="menu" href="cancellaimgpic.asp?id_files=<%=(del_scheda_t ech.Fields.Item("id_files").Value)%>" target="_blank">Cancella
    immagine piccola</a>

    <a class="menu" href="cancellaimgra.asp?id_filesHi=<%=(del_scheda_ tech.Fields.Item("id_filesHi").Value)%>" target="_blank">Cancella
    immagine grande</a></td>
    </tr>
    <tr>
    <td width="400" height="15" class="menu">
    <input type="hidden" name="MM_delete" value="form2">
    <input type="hidden" name="MM_recordId" value="<%= del_scheda_tech.Fields.Item("id").Value %>"></td></tr>
    </table></div></form>
    <%
    Repeat1__index=Repeat1__index+1
    Repeat1__numRows=Repeat1__numRows-1
    del_scheda_tech.MoveNext()
    Wend
    %>
    </div>
    </body>
    </html>
    <%
    schede_tech.Close()
    Set schede_tech = Nothing
    %>
    <%
    del_scheda_tech.Close()
    Set del_scheda_tech = Nothing
    %>

  2. #2
    While ((Repeat1__numRows <> 0) AND (NOT del_scheda_tech.EOF))
    perchè quando crei l'elenco delle schede inserite da eliminare tu gli dici di crearti la singola riga se è presente il record nel database (in del_scheda_tech). naturalmente se tu cancelli la scheda al refresh della pagina non vedrai la riga in cui c'era quella scheda tecnica e quindi neanche l'immagine associata

    trova un'altra soluzione oppure fai in modo che quando cancelli la scheda cancelli anche l'immagine

    forse potresti fare che crei un'elenco di immagini e mostri a sinistre le schede tecniche associate con i pulsanti elimina/modifica. in quel modo anche dopo l'elimina della scheda vedresti sempre l'immagine ma senza la scheda tecnica a fianco

    ciaoz

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.