Return MAX record in SQL statement HELP

  • Thread starter Thread starter Duppypog
  • Start date Start date
D

Duppypog

I'm using asp.net with an Access database. I have a field in the table
named "dtLastUpdated" which contains a date-time stamp when the record was
added to the database. I want to display just the lasted date/time in a
label on the page.

I created a Repeater and used the following SQL statement:
Dim strSQL As String = "SELECT Max(tblInmateLoc.dtLastUpdated) AS
theLastUpdated FROM tblInmateLoc"



ASP.NET does NOT like this sql. What am I doing wrong??

I'm REALLY new at this, so this may not have been the best approach - if you
know a better one, I'd love to hear it!

Thanks much,
Lynnette
 
Should say "I want to display just the LATEST date/time in a label on the
page.

sorry for the confusion
 
Without seeing more of the code, I am not sure. The SQL seems okay, so what
is the error message?

You can get a single value back like so:

Dim LastUpdated As DateTime = sqlComm.ExecuteScalar()

Since there is only one value, this should work. I have not worked with
Access lately, so it may present some pain.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
Author: ADO.NET and XML: ASP.NET on the Edge

****************************************************************************
****
Think Outside the Box!
****************************************************************************
****
 
Back
Top