Article View: borland.public.cppbuilder.database.ado
Article #1548Re: Use of SQL MAX for MS ACCESS file
From: Viatcheslav V. Vassiliev
Date: Thu, 13 May 2004 18:28
Date: Thu, 13 May 2004 18:28
40 lines
2110 bytes
2110 bytes
Try SELECT TOP 1 * FROM ConfigHistory ORDER BY Active DESC This should be easer for Access to optimize. //------------------------------------------ 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) "Martin Moeller" <martin.moeller@moema.it> �������/�������� � �������� ���������: news:40a3b5c2$1@newsgroups.borland.com... > Hi, > > I have an MS ACCESS file with a table called ConfigHistory and a column > called Active of type DATETIME, which is also PRIMARY KEY. > > What I want to do is to load in an ADODataSet just the very last record, > which is the one with the highest DATETIME value. > Ho do you do it? > > This works fine (loads all field specs) > > // Connection is open and set > SqlStr="SELECT * FROM ConfigHistory;"; > AdsCnfHist->CommandText=SqlStr.c_bstr(); > AdsCnfHist->Open(); > > But this generates error > > SqlStr="SELECT * FROM ConfigHistory" > "WHERE Active=(SELECT MAX(Active) FROM ConfigHistory);"; > > Tks & Rgds, Martin > >
Technical Details
Message-ID:
<40a3be67$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!controlnews3.google.com!news1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<40a3b5c2$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 10698b,4ddc4486a34d3345 X-Google-Attributes: gid10698b,public From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com> Newsgroups: borland.public.cppbuilder.database.ado References: <40a3b5c2$1@newsgroups.borland.com> Subject: Re: Use of SQL MAX for MS ACCESS file Date: Thu, 13 May 2004 22:28:57 +0400 Lines: 42 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 213.234.218.42 Message-ID: <40a3be67$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1084472935 213.234.218.42 (13 May 2004 11:28:55 -0700) Path: arc1-ca.pugleaf.net!controlnews3.google.com!news1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail