🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #1547

Use of SQL MAX for MS ACCESS file

#1547
From: Martin Moeller
Date: Thu, 13 May 2004 17:52
22 lines
1536 bytes
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: <40a3b5c2$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!controlnews3.google.com!news2.google.com!news.maxwell.syr.edu!newscore.univie.ac.at!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10698b,4ddc4486a34d3345,start
X-Google-Attributes: gid10698b,public
Reply-To: "Martin Moeller" <martin.moeller@moema.it>
From: "Martin Moeller" <martin.moeller@moema.it>
Newsgroups: borland.public.cppbuilder.database.ado
Subject: Use of SQL MAX for MS ACCESS file
Date: Thu, 13 May 2004 19:52:02 +0200
Lines: 24
Organization: Moe.Ma Italiana Srl
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.45.0.185
Message-ID: <40a3b5c2$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1084470722 213.45.0.185 (13 May 2004 10:52:02 -0700)
Path: arc1-ca.pugleaf.net!controlnews3.google.com!news2.google.com!news.maxwell.syr.edu!newscore.univie.ac.at!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail