Detect time of last change on a Microsoft Access database table

后端 未结 4 817
甜味超标
甜味超标 2021-01-17 00:00

Does anyone know of a way to detect when the last time a Microsoft Access table has been changed (inserted into or updated)? We used OLEDB via ADO COM to communicate with a

4条回答
  •  不要未来只要你来
    2021-01-17 00:47

    The only way to detect if data in the table has changed is to perform a query against the table.

    You must add a column of type DATETIME to the table e.g. named LastUpdatedDate that indicates the last updated date/time of each row. Make it NOT NULL so that you will have to write an updated DATETIME value to that column for each INSERT or UPDATE. Also, set the column to have a default of DATE() for the current date stamp or NOW() for the current date/time stamp. Then add a Validation Rule or CHECK constraint e.g. CHECK (LastUpdatedDate = NOW()) to ensure the column is actually updated on each UPDATE and INSERT.

    Finally, run a MAX(LastUpdatedDate) query and you will get what you need.

提交回复
热议问题