473,396 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Saving concurrently on DB?

VMI
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.

Sep 5 '06 #1
1 1158
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.

Sep 5 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: meng | last post by:
is it possible to use a single connection object shared by several tasks where each task is handled by a thread? these tasks call stored procedures that return record sets, no editing, update or...
3
by: Chris Anderson | last post by:
Could someone please tell me how I ensure only one instance of an application can execute concurrently?
14
by: Amitabh Deepak | last post by:
Is there any way to check whether daylight saving is enabled on a linux machine?
4
by: John Kandell | last post by:
Hi, I posted this in the asp.net group, but didn't get a response. Maybe someone here can help me with this... --- Would someone be able to shed some light on what is the cost of saving a...
0
by: Brian Parker | last post by:
I created a new solution with 2 projects: a) A C# Web Service that pauses for 15 seconds then returns a string. b) A C# Web Application that calls the web service and displays the string. ...
4
by: Pedro Leite | last post by:
Good Afternoon. the code below is properly retreiving binary data from a database and saving it. but instead of saving at client machine is saving at the server machine. what is wrong with my...
5
by: Frederick Gotham | last post by:
The Standard says that the behaviour is unspecified with regard to the order of evaluation in the following: int FuncA(); int FuncB(); int main() { FuncA() + FuncB(); }
27
by: RobG | last post by:
I was investigating a function to determine whether daylight saving was being observed on a particular date (given the platform's regional settings) and came across a suggestion at merlyn.com to...
2
by: Elikhom | last post by:
Is there any way to open multiple files concurrently and for example read the first line of each and the do some task with them, then read the second line of all of them and do some task again with...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.