Current location: Hot Scripts Forums » Programming Languages » ASP » Delete Selected


Delete Selected

Reply
  #1 (permalink)  
Old 07-12-03, 10:27 AM
austin322 austin322 is offline
Newbie Coder
 
Join Date: Jul 2003
Location: Florence, MS
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Delete Selected

I have a list of records in the database on one of my pages. I have it setup, were you have to delete each record manually. I would like to add a checkbox beside the records, and a button to delete checked items, but when I set it up, when I checked some of the records the code I was using only delted the first record that I checked. Here is the code that I used:

<%
ScoreID=Request.QueryString("ScoreID")

set conn = server.CreateObject ("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("Quiz.mdb")
rs = "DELETE * FROM Scores WHERE ScoreID= " & ScoreID & ";"
conn.execute rs

conn.close
set conn=nothing
%>

Please Help!

Last edited by austin322; 07-12-03 at 03:08 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 07-12-03, 07:56 PM
Jenny Jenny is offline
Newbie Coder
 
Join Date: Jul 2003
Location: Stockholm
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Delete Selected

Quote:
Originally posted by austin322
I have a list of records in the database on one of my pages. I have it setup, were you have to delete each record manually. I would like to add a checkbox beside the records, and a button to delete checked items, but when I set it up, when I checked some of the records the code I was using only delted the first record that I checked. Here is the code that I used:

Please Help!
No problem!

little sample script to display delete form
--------------------------------------

<%
response.write "<form method=post action=delete.asp>"
sql = "select id, name from scores order by id desc"
rs.open sql, conn,3,3

do while not rs.eof

response.write "<input type=checkbox name=score value=" & rs("id") & ">" & rs("name")

rs.movenext
loop
response.write "</form>"
%>



script to delete (delete.asp)
---------------------------------------

<%
sql="delete from scores where id in (" & request("score") & ")"
conn.Execute sql,,adCmdText + adExecuteNoRecords
%>


This works definitly with MSSQL and should also work with Access or mySQL. Test it.

Jenny
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 07-13-03, 08:29 AM
austin322 austin322 is offline
Newbie Coder
 
Join Date: Jul 2003
Location: Florence, MS
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks, I was using an Access database, and it worked. Now all I need is a "Check All" Checkbox.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 07-13-03, 12:30 PM
Jenny Jenny is offline
Newbie Coder
 
Join Date: Jul 2003
Location: Stockholm
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Use JavaScript to activate all checkboxes...

Or put in an "if/then" statement before the SQL statement.

if request("clearall") then
sql="delete from scores"
else
sql="delete from scores where id in("&request("score")&")"
end if

Jenny
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Automated script to delete certain files shib_s Script Requests 3 08-03-06 06:28 PM
i know how to delete a file! but how to delete a directory? forcer JavaScript 3 01-28-04 08:00 AM
edit and delete data darkcarnival PHP 13 10-10-03 02:25 PM
Delete your own link MadDog Hot Scripts Forum Questions, Suggestions and Feedback 7 08-04-03 12:08 AM
select & delete mysql queries superman PHP 2 07-20-03 04:08 AM


All times are GMT -5. The time now is 11:45 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.