I have a server and many clients, my application is on clients and the database on the server, I have one table
Table --> Id --> int Auto-increment,
Name --> nvarchar(50),
So, whenever I insert a new line from the client with the request
Insert into Table Name Values('NameValue')
Inserts a row, and sql auto generates an Id field. So, to get my id, I use the following query
Select max(Id) as maxId from Table
but both requests are in different connections
It works well when only one client works, but when several clients work, many insert requests are requested by clients before I can request a getMaxId request.
source
share