This might be a very dumb question, but as the saying goes, "The only dumb question is the one you don't ask"...
I've got a SQL Server 2008 database and I want to lock a record for editing. However, another user might want to see information in that record at the same time. So, I want the first person in to be able to lock the record in the sense that they are the only ones who can edit it. However, I still want other users to see the data if they want to.
This is all done from a C# front end as it's gonna be on our Intranet.
Don't do your own locking - let SQL Server handle it on its own.
As long as you only
SELECT, you'll put what's called a shared lock on a row - other users who want to also read that row can do so.Only when your code goes to update the row, it will place an exclusive lock on the row in order to be able to update it. During that period of time, no other users can read that one single row you're updating - until you commit your transaction.