ADO.NET: what did you just say?

I need to do some processing when rows are deleted from my DataTable. One would think it should be easy: after all, you have RowDeleting and RowDeleted events, that should take care of the problem.

But the life is not that easy. When you get RowDeleting, the row has not been deleted yet, it is still in the table, which gets in the way of the processing logic. When you get RowDeleted, the row is not in the table, but you can’t tell what was in it: row[col] throws an exception: “the row is not in the table”, or something like that.

Who, may I ask, came up with this specification? It’s not like a row can never have values when it is outside the table: row values can be happily accessed before it is added to the table, but not after it is deleted. Sometimes the weak side of me starts to think that designers of database and quasi-database interfaces take some sadistic pleasure from inventing ridiculous limitations like this, although deep down I know this is not true.

Leave a Reply

Your email address will not be published. Required fields are marked *