i am selecting a record from the table.i want to lock that recordset when i select that particular record so that another user should not be able to modify that record.using ADO if am right locking is done during edit and update.can any one help me with locking during the select itself
To hold any locks you need to have an open transaction.
select * from tbl (tablockx, holdlock)
This will lock the table exclusively until the transaction is terminated.
To hold the transaction open it must be created on the spid by the application rather than in the stored procedure.
For your requirement you are probably better off having a separate table in with yuo hold the IDs of the record that the user is wanting to update and forcing the read for update SP to update this table.