Results 1 to 8 of 8
  1. #1
    Join Date
    Jul 2004
    Posts
    494

    Unanswered: record not erasing upon "delete"

    Why is it that the record is not erasing on "delete"?

    Code:
    <%@ LANGUAGE="VBSCRIPT" %>
    <!--#include file="adovbs.inc"-->
    <!--#include file="pagetop.txt"-->
    <!--#include file="isadmin.inc"-->
    <%
    if isAdmin then
    
    '************************************************************************************
    '* Declaration section
    '************************************************************************************
    ' Mode contstants
    Const MODE_DEFAULT  = 1
    Const MODE_RESULTS  = 2
    
    Const DB_NAME           = "kjv.mdb" ' Name of our database file
    Const SCRIPT_NAME       = "kjv.asp"  ' Name of this script
    Const SCRIPT_NAMES      = "kjvresp.asp"
    const SCRIPT_SAVED      = "saved.asp"
    Const SCRIPT_FEEDBACK   = "mailto.asp"
    Const SCRIPT_TEXT       = "bibletext.asp"
    
    Const RECORDS_PER_PAGE  = 20            ' Number of records per page
    
    Dim nMode   ' Current Mode
    
    '************************************************************************************
    '* End of Declaration section
    '************************************************************************************
    
    ' This function will generate our connection string
    ' it assumes that Access database is in the same folder as this script
    
    Private Function GetConnectionString()
        GetConnectionString =   "Driver={Microsoft Access Driver (*.mdb)};" & _
                    "DBQ=" & Server.MapPath(DB_NAME) & ";" & _
                    "UID=;PWD=;"
    End Function
    
    %>
    <CENTER>
    <H2> Edit Links</h2>
    
    <A HREF="my_edit_links_rec.asp">Create a New Record</A>
    <FORM ACTION="my_edit_links.asp" METHOD="post">
    <TABLE BORDER="1">
    <%
    
        'set outpostDB = Server.CreateObject("ADODB.Connection")
        'outpostDB.Open "outpost"
    
        'set tableSet = Server.CreateObject("ADODB.RecordSet")
        'tableSet.Open "select * from links order by link_id", outpostDB, adOpenForwardOnly, adLockOptimistic, adCmdText
    
    
        set rs = Server.CreateObject("ADODB.Connection")
        rs.Open "kjv"
    
        set tableSet = Server.CreateObject("ADODB.RecordSet")
        tableSet.Open "select * from results order by id", rs, adOpenForwardOnly, adLockOptimistic, adCmdText
    
        while not tableSet.EOF
    %>            <TR>
                <TD>
                    <INPUT TYPE="checkbox" NAME="p_delete" 
                                  VALUE="<%=tableSet("id")%>">
                </TD>
    <%            p_numberOfColumns = tableSet.Fields.Count
    %>             <TD>
                      <A HREF="my_edit_links_rec.asp?p_id=<%
                        Response.Write tableSet("id")%>">
                         <%= tableSet.Fields(0).Value %>
                    </A>
                  </TD>
    
    <%            for col = 1 to (p_numberofColumns-1)
    %>                   <TD>
                          <%= tableSet.fields(col).Value %>
                             </TD>
    <%            next  %>
                 </TR>
    <%        tableSet.MoveNext
        wend
        tableSet.Close
        set tableSet = Nothing
    %>
    
    </TABLE>
    <INPUT TYPE="submit" VALUE="Delete Checked Rows">
    </form>
    
    <A HREF="my_edit_links_rec.asp">Create a New Record</A>
    
    </CENTER>
    <%
        rs.Close
        set rs = Nothing
    else
    
        Response.Write "You do not have access to this page."
    
    end if
    %>
    </BODY>
    </HTML>

  2. #2
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    Probably because there's no code on that page that actually deletes anything..

    You should probably post my_edit_links.asp
    That which does not kill me postpones the inevitable.

  3. #3
    Join Date
    Jul 2004
    Posts
    494

    ok

    I looked at it. It seemed a bit complicated because there were links all over the codes. But I noticed method="post" but then linked to my_edit_links_action.asp . And that redirected to "http://local" host address, instead of the address I work on.

    Inserting query data from search into a new table:

    Is there a way to insert search data into new table? I have a "results" along with the "bible" table in the db. The fields have the same name. My intention is to display the "results" with the ability to delete records that I don't want but keep the table "bible" untampered.

    Do I have to open/close both tables simultaneously? How about the SQL? Is there any order of procedure?

  4. #4
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    Ok, why? Give us a high level flow of your page... someone does a search against the bible table, the results are displayed, and the user is able to remove results they don't want?

    So your idea is to store the results in a second table, then you could delete the results they didn't want from the second table? Who then clears out the results table? What happens if the user leaves the site? Your results table would explode in size..

    Now, I assume you have no middleware, so your best option is to simply keep track of the IDs of the rows the user doesn't want, and include that in your SQL statement.
    Last edited by Seppuku; 09-13-04 at 02:58.
    That which does not kill me postpones the inevitable.

  5. #5
    Join Date
    Jul 2004
    Posts
    494

    If you want to see online

    Here is the URL:
    http://n.1asphost.com/wheelofgod/kjv.asp
    Type in a word to search and you'll find the table in the kjvresp.asp

  6. #6
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    Right. Since you don't have any middleware to manage your results, you'll need to do it manually. When someone selects a few checkboxes and the "Delete" option from the dropdown menu, you need to store those IDs in a variable. Then you can use those IDs to exclude them from the list. So your SELECT statement would then include a bunch of "... AND ID <> 1 AND ID <> 2 AND ID <> 3 ..." groups
    That which does not kill me postpones the inevitable.

  7. #7
    Join Date
    Jul 2004
    Posts
    494

    how many and where?

    How many should I put and where?

  8. #8
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    How many what? You'll have one variable just to store all the excluded IDs. This will be on your results page. Keep those IDs in a "hidden" form field, and then when someone selects a new row to remove, you append the new ID to the list. Then before you issue your SQL on the kvjresp.asp page, you'll split out that hidden variable of IDs into an array and build a new string like "... AND ID <> 1 AND ID <> 2 AND ID <> 3 ..." which you'll append to your primary SQL statement.
    That which does not kill me postpones the inevitable.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •