Thanks for your reply, but in the meantime I found a solution for my problem and it's working with the following command:
dbCommand = New OleDbCommand("DELETE * FROM tblError WHERE (((tblError.ErrTime)<#" & Format(fourteenDaysBack, "yyyy-MM-dd) & "#))"
I just had to format the date. But I do not understand why I have to do this. But I'm happy that it's working.
But I have a problem with sql that looks the same. I have the following query
SELECT dbo.tblWinkel.AFK, dbo.tblImportCCD.CCDDatum, dbo.tblImportCCDDetail.CCDNaam, dbo.tblImportCCDDetail.CCDWaarde,
dbo.tblImportCCDDetail.CCDQty
FROM dbo.tblImportCCD INNER JOIN
dbo.tblWinkel ON dbo.tblImportCCD.WinkelFK = dbo.tblWinkel.WinkelPK INNER JOIN
dbo.tblImportCCDDetail ON dbo.tblImportCCD.ImportCCDPK = dbo.tblImportCCDDetail.ImportCCDFK
WHERE (dbo.tblImportCCD.CCDDatum > CONVERT(DATETIME, '2004-02-20', 102)) AND (dbo.tblWinkel.AFK = N'AAL_DEN') AND
(dbo.tblImportCCDDetail.CCDNaam = 'Bon 1 EUR') OR
(dbo.tblImportCCDDetail.CCDNaam = 'Bon 3 EUR') OR
(dbo.tblImportCCDDetail.CCDNaam = 'Maaltijdcheque') OR
(dbo.tblImportCCDDetail.CCDNaam = 'TicketRestaurant')
ORDER BY dbo.tblWinkel.AFK
But the problem is that I get alle the records back even the CCDDatum is less then 20/02/2004 and also all the other records where AFK isn't AAL_DEN.
The data type of CCDDAtum is datetime with size 8 and the datatype of AFK is nvarchar(50)
I really don't know what's going wrong because the selection of the CCDNaam is working. I only get the records with CCDNaam = 'Bon 1 EUR' or 'Bon 3 EUR' or 'Maaltijdcheque' or ' TicketRestaurant'
Does anyone knows what's wrong?