Article View: borland.public.cppbuilder.database.ado
Article #1549Re: Use of SQL MAX for MS ACCESS file
From: Viatcheslav V. Vassiliev
Date: Thu, 13 May 2004 18:32
Date: Thu, 13 May 2004 18:32
66 lines
2995 bytes
2995 bytes
Also WideString SqlStr = "..." AdsCnfHist->CommandText=SqlStr; without .c_bstr() - you assign one WideString to another. Your query may not work because there is no space between lines, finally it looks as: SELECT * FROM ConfigHistoryWHERE Active=(SELECT MAX(Active) FROM ConfigHistory); //------------------------------------------ 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) "Viatcheslav V. Vassiliev" <support@oledbdirect.com> �������/�������� � �������� ���������: news:40a3be67$1@newsgroups.borland.com... > 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:
<40a3bf2c$2@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!controlnews3.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> <40a3be67$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> <40a3be67$1@newsgroups.borland.com> Subject: Re: Use of SQL MAX for MS ACCESS file Date: Thu, 13 May 2004 22:32:14 +0400 Lines: 68 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: <40a3bf2c$2@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1084473132 213.234.218.42 (13 May 2004 11:32:12 -0700) Path: arc1-ca.pugleaf.net!controlnews3.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail