473,513 Members | 8,991 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help Isolating Data Access

I need help with what I think may be a design issue.

I need to access a record for processing. I need to do it in such a fashion that several concurrent processes do not access the same
record.

I've set up a stored procedure that first queries the table for a record to process than marks the record so that it is now
unavailable.

The process that executes this stored procedure runs on multiple threads on multiple machines.

My problem is that I have occasions where two or more threads access the same record at the same time which causes unwanted
redundant processing. IOW, I need to be able to guarantee that a record will never be processed by more than a single thread of
execution.

Does anyone have a solution or suggestion? Is there a design pattern for this?

FWIW, the parent process is a Windows Service written in C#.NET (v1.1) running against a SQL Server 2000 database.

ChrisG

Jul 21 '05 #1
2 1619
Chris:

Do you mean the record on the DB side or locally? If you mean on the db,
I'm not sure I understand. Let's say that I have record with a field called
CustNumber and process one with user Bill is accessing it. I pull the
record down into a dataset. During the select I mark the record as Used to
that the same query run now won't return the record b/c the where clause
specifies "where UsageFlag <> '1'" or whatever you do for indicating used.
Is this the scenario? Or do you mean you have 3 or four processes running
locally? If it's locally than you can sync lock the datatable (or the row)
and be done with it (well, that may be an overstatement, I don't want to
overgeneralize when we're talking about threading).

--
W.G. Ryan MVP Windows - Embedded

http://forums.devbuzz.com
http://www.knowdotnet.com/dataaccess.html
http://www.msmvps.com/williamryan/
"Chris Gallucci" <ch***@gallucci.com> wrote in message
news:eZ**************@TK2MSFTNGP12.phx.gbl...
I need help with what I think may be a design issue.

I need to access a record for processing. I need to do it in such a fashion that several concurrent processes do not access the same record.

I've set up a stored procedure that first queries the table for a record to process than marks the record so that it is now unavailable.

The process that executes this stored procedure runs on multiple threads on multiple machines.
My problem is that I have occasions where two or more threads access the same record at the same time which causes unwanted redundant processing. IOW, I need to be able to guarantee that a record will never be processed by more than a single thread of execution.

Does anyone have a solution or suggestion? Is there a design pattern for this?
FWIW, the parent process is a Windows Service written in C#.NET (v1.1) running against a SQL Server 2000 database.
ChrisG

Jul 21 '05 #2
"William Ryan eMVP" <do********@comcast.nospam.net> wrote in message news:OY**************@TK2MSFTNGP12.phx.gbl...
| Chris:
|
| Do you mean the record on the DB side or locally?
On the DB side.

| If you mean on the db,
| I'm not sure I understand. Let's say that I have record with a field called
| CustNumber and process one with user Bill is accessing it. I pull the
| record down into a dataset. During the select I mark the record as Used to
| that the same query run now won't return the record b/c the where clause
| specifies "where UsageFlag <> '1'" or whatever you do for indicating used.
| Is this the scenario?
Yes. And I do as you suggest in a stored procedure call in an attempt to isolate the selection/marking.

Or do you mean you have 3 or four processes running
| locally? If it's locally than you can sync lock the datatable (or the row)
| and be done with it (well, that may be an overstatement, I don't want to
| overgeneralize when we're talking about threading).
I have several threads that call the aforementioned SP. At times it happens that 2 more threads appear to call the SP at the same
time in which case they grab the same record.

| --
| W.G. Ryan MVP Windows - Embedded

ChrisG
Jul 21 '05 #3

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

Similar topics

9
3682
by: Steve | last post by:
Hello, I am writing a script that calls a URL and reads the resulting HTML into a function that strips out everthing and returns ONLY the links, this is so that I can build a link index of various...
8
4221
by: yerk5 | last post by:
Does js have some way of doing what I want here: I want to paste a multiline block of text into a TEXTAREA form field, and there is data in the block of text that I want to extract into a...
4
2296
by: Mike Thomas | last post by:
Access 2000 - Is there a 3rd party tool available, or perhaps some method built into Access 2000, which could isolate unused Access reports, queries, forms, etc? I have a 5 year old app which...
0
1049
by: Christian Rank | last post by:
Hello, I'm setting up a PostgreSQL installation accessible by many different users. The layout is: - all users connect to the same database - every user has its own schema, no write access to...
1
280
by: Chris Gallucci | last post by:
I need help with what I think may be a design issue. I need to access a record for processing. I need to do it in such a fashion that several concurrent processes do not access the same record. ...
66
5279
by: genestarwing | last post by:
QUESTION: Write a program that opens and read a text file and records how many times each word occurs in the file. Use a binary search tree modified to store both a word and the number of times it...
4
2493
by: Christian Maier | last post by:
Hi After surfing a while I have still trouble with this array thing. I have the following function and recive a Segmentation fault, how must I code this right?? Thanks Christian Maier
1
1586
by: jryanii | last post by:
hi i have a fla file of a website a friend gave me..i would love to use some of the features from the site.. all the code in in the fla file im having trouble isolating the correct pieces of...
10
3132
by: alhomam | last post by:
hi all, i found a program that provide a solution of how to create a timeline report similar to microsoft project i made my changes on the program some of the results is berfict and others...
0
7254
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7432
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7519
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
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1585
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.