I am working on an ASP.Net application with SQL Server 2000 as the back-end server.
I need to calculate the MAX value of the primary key of a table say TABLE_1 and then display MAX+1 for the new reord on the screen...which will be the primary key for the new record which is presently being edited by the user.
To maintain the uniqueness of the primary key, I need to retrieve the unique values of MAX from the database for the concurrent users. I am maintaining another Table TABLE_APP_COMMON for this purpose which conains a record namely MAX_TABLE_1 containing the maximum value used by the primary key field of
the table TABLE_1.
My problem is that if 2 users read this table TABLE_APP_COMMON simultaneously then they would get the same value for the
column MAX_TABLE_1. In order to avoid this I need to give exclusive read access to the users for the table
TABLE_APP_COMMON.
Could anybody tell me how to achieve this in ASP.Net, ADO.Net, SQL Server 2000.
Any help is greatly appreciated.
Thanks a lot in advance
I need to calculate the MAX value of the primary key of a table say TABLE_1 and then display MAX+1 for the new reord on the screen...which will be the primary key for the new record which is presently being edited by the user.
To maintain the uniqueness of the primary key, I need to retrieve the unique values of MAX from the database for the concurrent users. I am maintaining another Table TABLE_APP_COMMON for this purpose which conains a record namely MAX_TABLE_1 containing the maximum value used by the primary key field of
the table TABLE_1.
My problem is that if 2 users read this table TABLE_APP_COMMON simultaneously then they would get the same value for the
column MAX_TABLE_1. In order to avoid this I need to give exclusive read access to the users for the table
TABLE_APP_COMMON.
Could anybody tell me how to achieve this in ASP.Net, ADO.Net, SQL Server 2000.
Any help is greatly appreciated.
Thanks a lot in advance