following program list the date last modified for all tables in an access database. Here you are retrieving date as string(_bstr_t) type. You need to convert it to some of c++ date kind of data type to compare and find the latest among it. That logic you need to write yourself
#include <stdio.h>
#include <ole2.h>
#include <oleauto.h>
#import " C:/Program Files/Common Files/System/ado/msado15.dll" rename( "EOF", "AdoNSEOF" )
_bstr_t bstrConnect = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source= D:\\TestDB.accdb;";
using namespace std;
using namespace ADODB;
int main()
{
if ( FAILED(::CoInitialize(NULL)) )
return -1;
_ConnectionPtr pConnection = NULL;
_RecordsetPtr pRstSchema = NULL;
_bstr_t strCnn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\\MyTrainingDB\\Training.accdb;";
try {
pConnection.CreateInstance(__uuidof(Connection));
pConnection->Open (strCnn, "", "", adConnectUnspecified);
pRstSchema = pConnection->OpenSchema(adSchemaTables);
while ( !(pRstSchema->AdoNSEOF) )
{
_bstr_t table_type = pRstSchema->Fields->GetItem("TABLE_TYPE")->Value;
LPCSTR lpcszType = (LPCSTR) table_type;
LPCSTR lpcszTable = "TABLE";
if( 0 == strcmp( lpcszType, lpcszTable ))
{
_bstr_t table_name = pRstSchema->Fields->GetItem("TABLE_NAME")->Value;
printf("Table Name: %s\n",(LPCSTR) table_name);
_bstr_t table_date = pRstSchema->Fields->GetItem("DATE_MODIFIED")->Value;
printf("Table Modified Time: %s\n\n",(LPCSTR) table_date);
}
pRstSchema->MoveNext();
}
}
catch (_com_error &e)
{
}
if (pRstSchema)
if (pRstSchema->State == adStateOpen)
pRstSchema->Close();
if (pConnection)
if (pConnection->State == adStateOpen)
pConnection->Close();
::CoUninitialize();
getchar();
}