I have a visual foxpro system that I am migrating to a sql server database.
The system uses pessimistic record which I would like to replicate with the connections to SQL server.
I connect to the database using ODBC authenticating via active directory.
The steps of processing that usually occur as as follows:
1) User will select the details from the database
2) The user will click an "edit" button which will lock just that record in the specific table
3) User will then make changes to the record
4) The user either clicks a "save" to commit the transaction or "cancel" to rollback the changes
I have read a number of different posts on record locking of which the lock hints seems to be the one that would fit the best.
They seem to behave differently depending upon the types of indes you have on the table.
To test this I wrote a simple statement in SQL management studio below:
Index is CLUSTERED called pk_client_id on the field client_id
I then opened an spearate instance of SQL management studio and used the same select statement.
It allowed me to select the record back.
What I would have expected is the second occurance would have generated a record lock error because the first statement had locked the record.
Can someone let me know what I am doing wrong or a good article I can read on this.
Mark Davies
Warwickshire County Council
The system uses pessimistic record which I would like to replicate with the connections to SQL server.
I connect to the database using ODBC authenticating via active directory.
The steps of processing that usually occur as as follows:
1) User will select the details from the database
2) The user will click an "edit" button which will lock just that record in the specific table
3) User will then make changes to the record
4) The user either clicks a "save" to commit the transaction or "cancel" to rollback the changes
I have read a number of different posts on record locking of which the lock hints seems to be the one that would fit the best.
They seem to behave differently depending upon the types of indes you have on the table.
To test this I wrote a simple statement in SQL management studio below:
Code:
SELECT *
FROM [saw_test].[dbo].[client] WITH (ROWLOCK NOWAIT)
WHERE client_id = 1
Index is CLUSTERED called pk_client_id on the field client_id
I then opened an spearate instance of SQL management studio and used the same select statement.
It allowed me to select the record back.
What I would have expected is the second occurance would have generated a record lock error because the first statement had locked the record.
Can someone let me know what I am doing wrong or a good article I can read on this.
Mark Davies
Warwickshire County Council