If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > record not erasing upon "delete"

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-12-04, 19:33
gilgalbiblewhee gilgalbiblewhee is offline
Registered User
 
Join Date: Jul 2004
Posts: 494
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>
Reply With Quote
  #2 (permalink)  
Old 09-12-04, 19:42
Seppuku Seppuku is offline
Useless...
 
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.
Reply With Quote
  #3 (permalink)  
Old 09-12-04, 21:01
gilgalbiblewhee gilgalbiblewhee is offline
Registered User
 
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?
Reply With Quote
  #4 (permalink)  
Old 09-12-04, 22:54
Seppuku Seppuku is offline
Useless...
 
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.
__________________
That which does not kill me postpones the inevitable.

Last edited by Seppuku; 09-13-04 at 01:58.
Reply With Quote
  #5 (permalink)  
Old 09-13-04, 01:25
gilgalbiblewhee gilgalbiblewhee is offline
Registered User
 
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
Reply With Quote
  #6 (permalink)  
Old 09-13-04, 02:02
Seppuku Seppuku is offline
Useless...
 
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.
Reply With Quote
  #7 (permalink)  
Old 09-13-04, 10:17
gilgalbiblewhee gilgalbiblewhee is offline
Registered User
 
Join Date: Jul 2004
Posts: 494
how many and where?

How many should I put and where?
Reply With Quote
  #8 (permalink)  
Old 09-13-04, 12:22
Seppuku Seppuku is offline
Useless...
 
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On