Article View: borland.public.cppbuilder.database.ado
Article #1366Re: Data Type Mismatch in Criteria Expression
From: Viatcheslav V. Vassiliev
Date: Tue, 27 Jul 2004 07:35
Date: Tue, 27 Jul 2004 07:35
114 lines
4476 bytes
4476 bytes
For command that does not return records, use TADOCommand: ADOCommand1->ParamCheck = false; ADOCommand1->CommandText = "DELETE FROM test WHERE Col2 < #08/26/04 10:17:30#"; ADOCommand1->Execute(); ParamCheck should be false because there is ':' in command text. For Jet (Access) you may also need to write DELETE * FROM ... (not '*' char). Use parameter will set date using TDateTime and does not depend on string format: ADOCommand1->ParamCheck = true; ADOCommand1->CommandText = "DELETE FROM test WHERE Col2 < :param"; ADOCommand1->Parameters->Items[0]->Value = EncodeDate(2004, 8, 26); ADOCommand1->Execute(); //------------------------------------------ Regards, Vassiliev V. V. http://www.managed-vcl.com - using .Net objects in Delphi for Win32 + ADO.Net http://www.oledbdirect.com - The fastest way to access MS SQL Server, MS Jet (Access) and Interbase (through OLEDB) "Kim Utley" <kim@simsware.com> �������/�������� � �������� ���������: news:41055c66$1@newsgroups.borland.com... > Oops, > > Meant to say: > > > I wish to use a SQL statement because if I use TADOTable it wants to read > up > > all ROWS when I open the table. > > > "Kim Utley" <kim@simsware.com> wrote in message > news:41055bb8$1@newsgroups.borland.com... > > Am using Microsoft Access with TADOQuery and TADOConnection. > > > > What do you mean by 'use parameter'? > > > > I wish to to SQL statement because if I use TADOTable it wants to read up > > all columns when I open the table. > > > > adoQuery->SQL->Clear(); > > adoQuery->SQL->Add( "DELETE FROM EventHistoryTbl WHERE > > DateTimeStamp < '06/26/04 10:17:30'" ); > > > > // this is where the exception is thrown... > > // > > adoQuery->ExecSQL(); > > > > > > Kindest Regards, > > > > > > Kim > > > > "Viatcheslav V. Vassiliev" <support@oledbdirect.com> wrote in message > > news:41053e2f$1@newsgroups.borland.com... > > > It depends on DBMS. General solution that should work with any DBMS is > to > > > use parameter for dates. > > > > > > //------------------------------------------ > > > Regards, > > > Vassiliev V. V. > > > http://www.managed-vcl.com - using .Net objects in Delphi for Win32 + > > > ADO.Net > > > http://www.oledbdirect.com - The fastest way to access MS SQL Server, > > > MS Jet (Access) and Interbase (through OLEDB) > > > > > > "Kim Utley" <kim@simsware.com> �������/�������� � �������� ���������: > > > news:41052c3f$1@newsgroups.borland.com... > > > > Hi All, > > > > > > > > Am working on BCB 6 with TADO... objects, specifically TADOConnection > > and > > > > TADOQuery in my example problem. I am attempting to delete all rows in > a > > > > table that have a date/time stamp older than 'x' amount of days. > > > > > > > > I am issuing the following SQL statement be am getting "Data type > > mismatch > > > > in criteria express' exception: > > > > > > > > DELETE FROM EventHistoryTbl WHERE DateTimeStamp < '06/26/04 10:17:30' > > > > > > > > I've also tried: > > > > > > > > DELETE FROM EventHistoryTbl WHERE DateTimeStamp < #06/26/04 10:17:30# > > > > > > > > Does anyone know why I'm getting this error? > > > > > > > > Kindest Regards, > > > > > > > > > > > > Kim L. Utley > > > > > > > > > > > > > > > > > > > >
Technical Details
Message-ID:
<410605da$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<41052c3f$1@newsgroups.borland.com> <41053e2f$1@newsgroups.borland.com> <41055bb8$1@newsgroups.borland.com> <41055c66$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,8373fe4b7c83316d X-Google-Attributes: gid10698b,public X-Google-Language: ENGLISH,ASCII From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com> Newsgroups: borland.public.cppbuilder.database.ado References: <41052c3f$1@newsgroups.borland.com> <41053e2f$1@newsgroups.borland.com> <41055bb8$1@newsgroups.borland.com> <41055c66$1@newsgroups.borland.com> Subject: Re: Data Type Mismatch in Criteria Expression Date: Tue, 27 Jul 2004 11:35:57 +0400 Lines: 116 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 213.234.218.42 Message-ID: <410605da$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1090913754 213.234.218.42 (27 Jul 2004 00:35:54 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail