0

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

<% 
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!!

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by aparnesh
0

For Access, use

MYSQL = "DELETE FROM Request_detail WHERE Repdate between CDate('" & pdt &"') and CDate('" & cdt &"')"
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.