problem deleting records

Results 1 to 5 of 5

Thread: problem deleting records

  1. #1
    dummy Guest

    Default problem deleting records

    I have a form set up that everytime it calls the script in its action attribute it runs an sql delete to delete all records that are 7 days old it looks like this:<BR><BR>Dim RS, MyConn, SQL6, strDate<BR>strDate = Now()-7<BR>Response.Write "Debug: Date=" & strDate & "<BR>"<BR>Set MyConn=Server.CreateObject("ADODB.Connection")<BR> MyConn.Open "SE"<BR><BR>SQL6 = "DELETE FROM Banner WHERE ListingDate &#060; &#039;" & strDate & "&#039;"<BR><BR><BR>Set RS = MyConn.Execute(SQL6)<BR><BR><BR><BR>MyConn.Close<B R>Set MyConn = Nothing<BR><BR>I keep getting this error:<BR>Debug: Date=1/18/2001 12:14:10 AM<BR><BR>Microsoft OLE DB Provider for ODBC Drivers error &#039;80040e07&#039; <BR><BR>[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression. <BR><BR>/SE/addwin.asp, line 93 <BR><BR>any suggestions the field I&#039;m trying to delete is a date field and is set up that way in the access db<BR>thanks<BR>the big dummy<BR><BR>

  2. #2
    suresh Guest

    Default RE: problem deleting records

    Hey!<BR>The problem is simple.<BR>just remove the quotes arrount the date variable.<BR>like this.........<BR><BR>"DELETE FROM Banner WHERE ListingDate &#060; " & strDate & " "<BR><BR>since the date is not a string and it works surely.<BR>on more dubts u can contact me at<BR>

  3. #3
    Guhan Guest

    Default RE: problem deleting records

    Hai, Ensure the datatype for listing date is date and also contains the data in the same format as strDate returns. u can directly execute the query as it doesn&#039;t return anything<BR><BR><BR><BR><BR>

  4. #4
    Eddie Campbell Guest

    Default Almost right

    &#062;&#062; just remove the quotes arrount the date variable.<BR><BR>Yes, but as they are using Access, they will need to replace the single quotes with # marks around the date. It won&#039;t work without them.

  5. #5
    dummy Guest

    Default RE: problem deleting records

    thanks for your help all, it works great now appreciate it<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts