Current location: Hot Scripts Forums » Programming Languages » ASP » [SOLVED] Delete range of entries from database!!


[SOLVED] Delete range of entries from database!!

Reply
  #1 (permalink)  
Old 09-15-08, 06:02 AM
priyam priyam is offline
Newbie Coder
 
Join Date: Sep 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] Delete range of entries from database!!

Hi All

I am creating a database archiving tool,in which a user can delete all the data before a date he would specify.But the problem is i am not able to create a delete query which can delete a range of data.

I had created the following query
Code:
<% 
pdt=request.form("prevdate")   'contains the date starting from which data has to be deleted
cdt=request.form("currdate")    'contains the date till which data has to be deleted
' declaring variables
' not neccesary but a good habit
Dim DataConn
Dim CmdDeleteRecord
Dim MYSQL
    
Set DataConn = Server.CreateObject("ADODB.Connection")
  

Set CmdDeleteRecord = Server.CreateObject("ADODB.Recordset")
    
' The line below shows how to use a system DSN instead of a DNS-LESS connection
' DataConn.Open "DSN=System_DSN_Name"
DataConn.Open "DBQ=" & Server.Mappath("../fpdb/taxireq.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};"
    
MYSQL = "DELETE FROM Request_detail WHERE Repdate between '" & pdt &"' and '" & cdt &"'"
    
CmdDeleteRecord.Open MYSQL, DataConn
    
' closing objects and setting them to nothing
' not neccesary but a good habit
DataConn.Close
Set DataConn = Nothing
%>
please suggest any changes so that i can delete a range of data from the database

Thank You!!
Reply With Quote
  #2 (permalink)  
Old 09-29-08, 01:11 PM
Dwagar's Avatar
Dwagar Dwagar is offline
Newbie Coder
 
Join Date: Sep 2008
Location: Ohio
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
In MS Access if I remember correctly (Been a while) you would need to use

MYSQL = "DELETE FROM Request_detail WHERE Repdate between #" & pdt &"# and #" & cdt &"#"
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
Delete from database when ten entries already exist? hinch PHP 3 06-22-08 08:45 PM
Pulling info from database, but only showing certain entries mike_jandreau PHP 1 10-16-07 11:51 PM
Retrieving database entries php-learner PHP 1 11-26-06 04:01 AM
limit DELETE FROM mysql command to old entries - issue. clantron PHP 8 03-17-06 02:10 PM
Help with echo'ing rows of (td's) from database entries paulj000 PHP 6 04-20-04 09:32 AM


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