473,472 Members | 2,193 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Write Conflict Woes

14 New Member
Good afternoon, Byte'rs!

I'm running into an annoyance that, utilizing the framework I am, has been causing me grief. In a nutshell:

-Access 2003 Compiled ADE application
-SQL Server 2005 backend
-15 concurrent users

Normally our application has very specific workflows that handle how users get assigned specific records they're responsible for updating. This works well, because it pushes criteria to a Stored Proc that runs on the server, grabbing available records and putting them in a user's pipeline.

However, we've come across a situation that required us to bypass this process, and assign records to my users manually (by assigning, that means updating a text field with their initials which the application uses for workflow).

The problem we're having is that if two users go into the "Open" pipeline to manually grab a record, if two users grab the same record and start making udpates, when the second person goes to update they recieve the write conflict error.

I'm trying to come up with a way to have Access "look" to see if the record is updated before any changes are entered, but short of having a master LOCK / UNLOCK button that stores the locked status in a separate locking table, I'm coming up empty.

Any suggestions? :)
Sep 9 '09 #1
14 3305
NeoPa
32,556 Recognized Expert Moderator MVP
I guess not understanding what you are referring to by "pipeline" is causing me to find the question a bit confusing.

Is it a standard linked table?

How does your structure fit together (a brief explanation please)?
Sep 9 '09 #2
adversus
14 New Member
Yeah, sorry about that.

The "pipeline" is a user's queue, it's basically a recordset pulled down into the application for specific criteria, whatever the user selects (usually something like, "give me data set 1, data set 2, where the assign_box is my initials").

In this case I've got tables joined together. Updates are only being applied to the Right table (using a LEFT JOIN) that's created from a stored procedure and that SP is used as the record source of the form.

So essentially what I'm trying to do is prevent two users from modifying the same record.
Sep 9 '09 #3
NeoPa
32,556 Recognized Expert Moderator MVP
Maybe I'm still not getting something.

If your SP that provides the data for the pipeline as seen by each individual is in control of which data is sent, presumably on the basis that each record is only owned by one individual, then how can it send the same record concurrently to two different requestors?

Even assuming this is not quite working as expected then surely this is a problem with the SP rather than the Access portion of the project.

Maybe you can explain what I'm missing. It may be simply "the whole picture" of course, but let's see where we can get.
Sep 9 '09 #4
adversus
14 New Member
The problem is that user's can bypass their own pipeline and go out into a queue that does not have any assignments. In other words, records that are not already flagged by a user.

The problem I'm having is when this happens and two users modify the same record out of this data set, that the problem occurs.
Sep 10 '09 #5
NeoPa
32,556 Recognized Expert Moderator MVP
So the pipeline you're having problems with is a different one from the one you described in post #3 :S
Sep 10 '09 #6
adversus
14 New Member
Fair point. That's what I get for typing furiously in between meetings :)

Basically, how do I prevent two users who retrieved the same record from the server from causing a write conflict if they both do updates before the record gets refreshed/saved from the server.
Sep 10 '09 #7
NeoPa
32,556 Recognized Expert Moderator MVP
Well again, I don't see that this is a particularly Access issue here. I still don't have much of an understanding of the relevant pipeline, but guessing from what else you've said, it must be a queue of some sort provided by the SP that has no user level criteria associated.

This takes us back to the basics. If you want to provide such protection with your SP then fine, though we cannot generally help with that here (We don't even know what algorithms you're using - apart from it being non-Access in nature).

As far as Access record-locking goes, that is selected from the Options screen of the Tools menu. I'm really not sure that it even effects ODBC tables though.

Am I on the right track here? I'm not getting a sense that communication is going very well.
Sep 10 '09 #8
adversus
14 New Member
Yeah I apologize for that. It's been one of those weeks. I'm usually way easier to understand :)

Let me start over to clarify:

The form in question (and it is only one form) is bound to a stored procedure, lets call it "SP1". SP1 accepts several parameters, which it uses as criteria for a series of SELECT statements to retrieve the particular data a user requests. For example:

Expand|Select|Wrap|Line Numbers
  1. CREATE PROCEDURE [dbo].[SP1]
  2.    (@p_cParm1 CHAR(15) = NULL
  3.    ,@p_cParm1 CHAR(75) = NULL
  4.    ,@p_vAssigned VARCHAR(4) = NULL)
  5. AS
  6.  
  7. BEGIN
  8.    SELECT * FROM dbo.some_table
  9.    WHERE (@p_cParm IS NULL OR some_field = @p_cParm1)
  10.    AND (@p_cParm2 IS NULL OR some_field2 = @p_cParm2)
  11.    AND (@p_vAssigned IS NULL OR LTRIM(RTRIM (assgn_cd)) = @p_vAssigned)
  12. END
It's much longer and more complex than this, with more parameters, but this is the gist. Essentially the SP will return to access a record set from the SELECT statement, which is built with the criteria passed. In our case, the Assigned parameter may or may not be passed, and if it's left NULL, all records that match Parm1 and Parm2 are returned, regardless of the Assigned field status.

Now assume two users call this SP within minutes of each other without supplying the Assigned parameter. They may get the same record(s). Access retrieves the record set and uses this to populate the form (using the form's .InputParameters property). The same record is now displaying on two user's applications.

One user then modifies the record, and closes the form or navigates away which causes Access to push the update to the server. The second user does the same, and recieves a Write Conflict error, because they both had pending edits before one user saved.

The part I'm stuck at is figuring out a mechanism to have the application (i.e. Access) do one of the following:

1. Keep track of when a record becomes "locked" for editing, which can be displayed to the user, or
2. Something else I can't think of

Clear as mud? :)
Sep 10 '09 #9
ADezii
8,834 Recognized Expert Expert
@adversus
I have an idea, but I'm not exactly sure as to whether or not it will work. This simple process will be illustrated below. The majority of the code will be encapsulated within a Function, a simple Call to the Function will suffice. The general idea is to:
  1. Create a Clone of the Current Form's Recordset which is based on the Stored Procedure.
  2. Sync the Clone to the Form's Current Record by equating Bookmarks.
  3. Attempt to Edit the Clone. If the Record is Locked, an Error should occur, the Function returns True (is Locked), and then the Function is exited. If not, then the Function returns False.
  4. Check the return Value of the Function being sure to pass the Current Form as an Argument to the Function.
  5. Sounds good in theory, I'll let you actually try it and let me know if it actually works! (LOL)!
  6. Function Definition:
    Expand|Select|Wrap|Line Numbers
    1. Public Function fIsRecordLocked(frm As Form)
    2. Dim rst As DAO.Recordset
    3. On Error GoTo HandleErr
    4.  
    5. 'Clone the Form's Recordset and synch up to the
    6. 'Form's Current Record
    7. Set rst = frm.RecordsetClone
    8. rst.Bookmark = frm.Bookmark
    9.  
    10. 'If the Current Record is locked, then the next
    11. 'statement should produce an Error that we will trap.
    12. 'The Error Value should be 3188.
    13. rst.Edit
    14.  
    15. fIsRecordLocked = False
    16.  
    17. ExitHere:
    18.   Exit Function
    19.  
    20. HandleErr:
    21.   fIsRecordLocked = True    'Probably Locked (3188)
    22.     Resume ExitHere
    23. End Function
  7. Typical Call to fIsRecordLocked():
    Expand|Select|Wrap|Line Numbers
    1. If fIsRecordLocked(Me) Then
    2.   '..Record is Locked
    3. Else
    4.   'Record not Locked
    5. End If
  8. Kindly let me know how this turns out.
Sep 11 '09 #10
adversus
14 New Member
ADezii, thanks for the direction. I didn't think about using clone record set to check for record locks, so I'll try this and see what happens. I may not get to it today, but I'll try within a few days and get back to you :)
Sep 11 '09 #11
adversus
14 New Member
ADezii, I just tried your solution and every test results in a Locked result. I'm running it in a test environment where I'm the only user, so it's generated the locked result even with only one user in the system.
Sep 11 '09 #12
adversus
14 New Member
Aha, it's failing every time on the record locks, it's returning locked each time because it's erroring on:

Set rst = frm.RecordsetClone

Type Mismatch.

Because my Form is based on a SQL Stored Procedure, I couldn't use DAO. So I changed the recordset to an ADODB object and it resolved the Type Mismatch, however I'm having trouble finding the equivelant method for of "Edit" for ADO recordsets.
Sep 11 '09 #13
NeoPa
32,556 Recognized Expert Moderator MVP
@adversus
Aha. This seems to be the ongoing question of how and when to lock data. Either method has some problems associated with it :
  1. Lock it when you express an interest in updating (on first read) and the user may go off to lunch leaving it locked indefinitely.
  2. Lock it when you are ready with the data inside the code and it is perfectly possible for multiple users to have an update interest in the same record. This way leads to upset users if their updates are dropped in the bit bucket.
This is (no mistake about it) a fairly complicated subject with many considerations and related issues. Updating with deltas just one example of solutions to this problem (minimises rather than solves the problem tbh).

Having said that, I would expect any system (SQL Server; Access; Oracle; etc) to have their own inbuilt locking mechanism implemented. I'm afraid I'm no expert on how each has been implemented as I simply haven't had much need for it in my experience.

I do know that recordset updates in code require a command (.Edit & .AddNew I believe) that locks access to that record before updates are allowed. I think .Update saves and releases the record. How SPs in SQL Server (T-SQL based) handle the same I don't know I'm afraid.

While it's possible to implement similar locking mechanisms in code, I wouldn't suggest it generally. I would expect it to be considerably slower than any inbuilt mechanisms, and quite complicated to implement. In fact this whole subject can be researched on the web. I'm sure their are articles that explain all the details. Not something one could easily knock up in 5 minutes you understand.

I'm sorry I couldn't be more help.
Sep 11 '09 #14
ADezii
8,834 Recognized Expert Expert
@adversus
With ADO, try setting a Field on the Form equal to itself, then invoke the Update Method. This should be interpreted as an Edit, and no harm will be done either way. If the Record is Locked an Error will occur and the Field will never be Updated while if the Record is not Locked it will be Updated to itself.
Expand|Select|Wrap|Line Numbers
  1. rst![LastName] = frm![txtLastName]
  2. rst.Update
Sep 11 '09 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Max | last post by:
Hi, I have SqlServer 2000 as back end and Access 2000 as front-end. All tables from Sqlserver are linked to Access 2000. I am having write conflict problem with one of my form which is bound to...
2
by: RC | last post by:
I am getting the following error message. "Write Conflict this record has been changed by another user since you started edting it. If you save the record, you will overwrite the changes...." I...
1
by: shumaker | last post by:
I've loked over older messages on this, but haven't found a solution. I have a datasheet of records, and each record has a subform that can be viewed with the expand '+' symbol. The subform...
5
by: Simon | last post by:
Dear reader, I have two Forms they are both working with dada from the same tables. By typing in some changes in Form-B the changes are also visible in Form-A. There is no record lock...
1
by: Kuriandungu | last post by:
Hi guys I've read the posts on Write conflict entered in this forum (along with some from kbAlertz and microsoft) and i have tried all the solutions without success. let me give you some background....
4
by: crystal | last post by:
I've checked the threads but haven't been able to come up with a solution to my issue. Help...... I have a simple form based on a table. Within the form is a subform that is also, through a Q,...
1
by: lorirobn | last post by:
Hi, I have a query that I have been using as a record source for a form with no problems. I just created a new "addnew" form, and added 20 records to the table with this form. The problem I...
8
by: christianlott1 | last post by:
After searching the group and the net, I just can't believe after all this work I'm going to have to sit through three Write Conflict messages when I want to roll back and delete a record. The...
1
by: S.Dickson | last post by:
I have a database with access as front end and Mysql as back end. I am gettting the following 'Write Conflict' Error. when i am on my order form, This form does has a subform where i enter all the...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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...
1
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
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
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
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 ...

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.