VMI,
You don't have to necessarily handle the fact that two users are trying
to do the same thing at the same time. SQL Server will take care of that
for you.
However, what you do have to worry about is the user failing the
database operation when someone beats you to it. Since .NET is a
disconnected data model, meaning, you load the data, change it, then save it
back, it is possible that someone might have changed the database before you
get a chance to save it back. If you save your info, you will be
overwriting any changes that the user before you made.
To handle that you need to place something on your table, a timestamp of
some sort (binary, or a date) and check it when you update the table. You
basically check to see if the timestamp is different from the value you have
now. If it is, then you don't update the record, and you inform the user
that someone else has updated the record they were working on.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"VMI" <VM*@discussions.microsoft.comwrote in message
news:B5**********************************@microsof t.com...
I'm working on a web application that will store employees on to a sql
server
db. My Employee class consists of several variables (emplcode, fname,
lname,
lname2) and everytime the user saves a new employee, it'll fill all those
variables and do an SQL INSERT. Is this the best way to store data when
several users are inserting "concurrently"? For example, what would happen
if
user1 clicks "Finish" and starts the DB insertion process and, while it's
inserting, user2 clicks on "Finish"? Do I need code to manage the fact
that
two users are inserting at the same time?
Thanks.