I have a site that uses MS Access. People add records to the database including a date, dd/mm/yyyy format. All I want to do is run a statement that will delete all records where the date that the user entered is past.
I keep getting this message
Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
/delete1.asp, line 38
This is my current code although it is a bit of a mess. Please help.
Thanks
Matthew Wilde
matthew@ukwebsite.com
<%@ LANGUAGE="VBScript" %>
<%
Option Explicit
Response.Expires = 0
Session.LCID = 2057
%>
<!-- #INCLUDE FILE="adovbs.inc" -->
<%
Dim lngRecsAffected
Dim cnnFormToDB
Dim DateOfEvent, strType, strQ, objRS, objConn, sConnString
if Request.ServerVariables("QUERY_STRING" <> "" Then
DateOfEvent = cdate(Date)
strType = Request.QueryString("Type"
%>
<html><body>
<%
Set objConn = Server.CreateObject("ADODB.Connection"
sConnString = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ=" & Server.MapPath("/Database/tickets.mdb" & ";"
objConn.Open(sConnString)
Set objRS = Server.CreateObject("ADODB.Recordset"
strQ = ""
strQ = strq & "DELETE FROM concerts WHERE DateOfEvent = "
strQ = strQ & "'" & DateOfEvent & "'"
strQ = strQ & ";"
objConn.Execute strQ
objConn.Close
Set objConn = Nothing
%>
<font face=Arial size=2><b>
<H2>All records before <%= DateOfEvent %> have been deleted!</H2>
<font face=Arial size=2><b>
<P>
<B>If you spelt the record name correct - please check to see if the record has gone</B><br><br>
<p><font size="2" face="Arial"><a href="../<%= strType %>/index.asp"><b>View Results</b></a></font></p>
</P>
</body></html>
<%
Else
%>
<html><body>
DELETE todays date is <%= date %><BR>
<Form action="<% Request.ServerVariables("SCRIPT_NAME" %>" METHOD="GET">
<p><select size="1" name="Type">
<option value="Concerts">Concerts</option>
</select>
<input type="submit" name="submit" value="submit form">
</form>
</body></html>
<% end if %>
I keep getting this message
Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
/delete1.asp, line 38
This is my current code although it is a bit of a mess. Please help.
Thanks
Matthew Wilde
matthew@ukwebsite.com
<%@ LANGUAGE="VBScript" %>
<%
Option Explicit
Response.Expires = 0
Session.LCID = 2057
%>
<!-- #INCLUDE FILE="adovbs.inc" -->
<%
Dim lngRecsAffected
Dim cnnFormToDB
Dim DateOfEvent, strType, strQ, objRS, objConn, sConnString
if Request.ServerVariables("QUERY_STRING" <> "" Then
DateOfEvent = cdate(Date)
strType = Request.QueryString("Type"
%>
<html><body>
<%
Set objConn = Server.CreateObject("ADODB.Connection"
sConnString = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ=" & Server.MapPath("/Database/tickets.mdb" & ";"
objConn.Open(sConnString)
Set objRS = Server.CreateObject("ADODB.Recordset"
strQ = ""
strQ = strq & "DELETE FROM concerts WHERE DateOfEvent = "
strQ = strQ & "'" & DateOfEvent & "'"
strQ = strQ & ";"
objConn.Execute strQ
objConn.Close
Set objConn = Nothing
%>
<font face=Arial size=2><b>
<H2>All records before <%= DateOfEvent %> have been deleted!</H2>
<font face=Arial size=2><b>
<P>
<B>If you spelt the record name correct - please check to see if the record has gone</B><br><br>
<p><font size="2" face="Arial"><a href="../<%= strType %>/index.asp"><b>View Results</b></a></font></p>
</P>
</body></html>
<%
Else
%>
<html><body>
DELETE todays date is <%= date %><BR>
<Form action="<% Request.ServerVariables("SCRIPT_NAME" %>" METHOD="GET">
<p><select size="1" name="Type">
<option value="Concerts">Concerts</option>
</select>
<input type="submit" name="submit" value="submit form">
</form>
</body></html>
<% end if %>