I'm trying to use optimistic locking with SQL Server. When I run my update, I want to make sure that the timestamp I have is the most recent one, and also read in the newest value, and I'd like to do this in ONE query. I was thinking something like
UPDATE table SET .... WHERE keyField = @blah AND timestampField = @ts; SELECT timestampField from table WHERE keyField=@blah;
The problem is, I'm not sure how to tell how many rows were updated.
If I were using ExecuteNonQuery it would return the row count to me, but now I need ExecuteScalar to get me the timestamp, and so I'm not quiyte sure how to get the number of rows updated from the first part of it.