'System.Data.DBConcurrencyException when Select query includes TimeStamp

I have this table:

CREATE TABLE `Covid_Test` (
  `ID` int NOT NULL AUTO_INCREMENT,
  `PersonName` varchar(245) DEFAULT NULL,
  `DOB` date DEFAULT NULL,
  `TimeStamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `ResultStatus` varchar(245) DEFAULT NULL, 
  `Locale` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`ID`),
  UNIQUE KEY `ID_UNIQUE` (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=5623 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

In my DataSet I have a table with tableadapter with the following select query:

SELECT * FROM  Covid_Test

In the dataset, I have the TimeStamp column set to ReadOnly = True, and AllowDBNull = True. I have also removed the TimeStamp column from the Update Query.

When I try update a record with:

Me.Covid_TestBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.BusinessManagerDataSet)

I get a concurrency error. I have found that if I include the TimeStamp column in the update query I saves the original datetime and doesn't update when the record is saved. If I exclude it from the select and update query it updates correctly, but I am not able to see the value in the User UI.

Is there something I am missing that will allow me to include it in the select but update in the DB when saved. If I disable Optimistic Concurrency it saves as expected. But I would like to understand if my approach is wrong or I am missing something.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source