We have .mdb files of MS Access 2003 and we have to find out last date when this database was used. We have to do it programmaticly like read .mdb file and find out last used date. Also we need to figure out last modified and date of database creation.
Development Environment:- Visul Studio 2010,C#,Windows Form
Solution:- This may help others in future.
string query = "SELECT MSysObjects.DateCreate,MSysObjects.DateUpdate FROM MSysObjects WHERE Type=2";
string[] arrDate = getDBCreationAndModificationDates(query);
private string[] getDBCreationAndModificationDates(string query)
{
string[] arrDate = new string[2];
dao.Database db = appclass.CurrentDb();
dao.Recordset rs = null;
rs = db.OpenRecordset(query, Type.Missing, Type.Missing, Type.Missing);
string strDate=string.Empty;
if (rs != null)
{
arrDate[0] = rs.Fields[0].Value.ToShortDateString();
arrDate[1] = rs.Fields[1].Value.ToShortDateString();
}
rs.Close();
db.Close();
return arrDate;
}