Solved

Update Command Concurrency error - Specific Help

Posted on 2009-04-03
2
169 Views
Last Modified: 2013-12-25
I get a concurrency error when I update my table.  If I ad a new record via "INVENTORY_DRIBindingSource.AddNew()" and then Me.INVENTORY_DRIBindingSource.EndEdit()
        Me.INVENTORY_DRITableAdapter.Update(Me.DIMMSDataSet.INVENTORY_DRI).  All Works fine.  If I open up that specific record & make a change then run:
Me.INVENTORY_DRIBindingSource.EndEdit()
        Me.INVENTORY_DRITableAdapter.Update(Me.DIMMSDataSet.INVENTORY_DRI)
I get the error. Below is my FillByID code...maybe that is the issue.
SELECT     INVENTORY_DRI.PartID, INVENTORY_DRI.PartName, INVENTORY_DRI.PartDescription, INVENTORY_DRI.StockingUnits, INVENTORY_DRI.Location, 

                      SUM(TRX_ROW_DRI.PartsMade - TRX_ROW_DRI.QtyBad) AS PartBalance, INVENTORY_DRI.ID, INVENTORY_DRI.UnitWeight, 

                      INVENTORY_DRI.PartNumber, INVENTORY_DRI.UPC_SKU, INVENTORY_DRI.ItemType, INVENTORY_DRI.ReOrderQty, INVENTORY_DRI.PrefVendor, 

                      INVENTORY_DRI.InActive, INVENTORY_DRI.Offsite, INVENTORY_DRI.OffsiteLocation, INVENTORY_DRI.CostPerUnit, INVENTORY_DRI.DefPurch, 

                      INVENTORY_DRI.Location2

FROM         INVENTORY_DRI LEFT OUTER JOIN

                      TRX_ROW_DRI ON INVENTORY_DRI.PartID = TRX_ROW_DRI.PartID

GROUP BY INVENTORY_DRI.PartID, INVENTORY_DRI.PartName, INVENTORY_DRI.PartDescription, INVENTORY_DRI.StockingUnits, INVENTORY_DRI.Location, 

                      INVENTORY_DRI.ID, INVENTORY_DRI.UnitWeight, INVENTORY_DRI.PartNumber, INVENTORY_DRI.UPC_SKU, INVENTORY_DRI.ItemType, 

                      INVENTORY_DRI.ReOrderQty, INVENTORY_DRI.PrefVendor, INVENTORY_DRI.OffsiteLocation, INVENTORY_DRI.InActive, INVENTORY_DRI.Offsite, 

                      INVENTORY_DRI.CostPerUnit, INVENTORY_DRI.DefPurch, INVENTORY_DRI.Location2

HAVING      (INVENTORY_DRI.ID = @Param1)

 

UPDATE COMMAND:

 

UPDATE    INVENTORY_DRI

SET              PartID = @PartID, PartName = @PartName, PartDescription = @PartDescription, UnitWeight = @UnitWeight, StockingUnits = @StockingUnits, 

                      PartNumber = @PartNumber, UPC_SKU = @UPC_SKU, ItemType = @ItemType, Location = @Location, Location2 = @Location2, 

                      ReOrderQty = @ReOrderQty, PrefVendor = @PrefVendor, InActive = @InActive, Offsite = @Offsite, OffsiteLocation = @OffsiteLocation, 

                      CostPerUnit = @CostPerUnit, DefPurch = @DefPurch, PartBalance = @PartBalance

WHERE     (ID = @Original_ID) AND (PartID = @Original_PartID) AND (@IsNull_PartName = 1 AND PartName IS NULL OR

                      PartName = @Original_PartName) AND (@IsNull_PartDescription = 1 AND PartDescription IS NULL OR

                      PartDescription = @Original_PartDescription) AND (@IsNull_UnitWeight = 1 AND UnitWeight IS NULL OR

                      UnitWeight = @Original_UnitWeight) AND (@IsNull_StockingUnits = 1 AND StockingUnits IS NULL OR

                      StockingUnits = @Original_StockingUnits) AND (@IsNull_PartNumber = 1 AND PartNumber IS NULL OR

                      PartNumber = @Original_PartNumber) AND (@IsNull_UPC_SKU = 1 AND UPC_SKU IS NULL OR

                      UPC_SKU = @Original_UPC_SKU) AND (@IsNull_ItemType = 1 AND ItemType IS NULL OR

                      ItemType = @Original_ItemType) AND (@IsNull_Location = 1 AND Location IS NULL OR

                      Location = @Original_Location) AND (@IsNull_Location2 = 1 AND Location2 IS NULL OR

                      Location2 = @Original_Location2) AND (@IsNull_ReOrderQty = 1 AND ReOrderQty IS NULL OR

                      ReOrderQty = @Original_ReOrderQty) AND (@IsNull_PrefVendor = 1 AND PrefVendor IS NULL OR

                      PrefVendor = @Original_PrefVendor) AND (@IsNull_InActive = 1 AND InActive IS NULL OR

                      InActive = @Original_InActive) AND (@IsNull_Offsite = 1 AND Offsite IS NULL OR

                      Offsite = @Original_Offsite) AND (@IsNull_OffsiteLocation = 1 AND OffsiteLocation IS NULL OR

                      OffsiteLocation = @Original_OffsiteLocation) AND (@IsNull_CostPerUnit = 1 AND CostPerUnit IS NULL OR

                      CostPerUnit = @Original_CostPerUnit) AND (@IsNull_DefPurch = 1 AND DefPurch IS NULL OR

                      DefPurch = @Original_DefPurch) AND (@IsNull_PartBalance = 1 AND PartBalance IS NULL OR

                      PartBalance = @Original_PartBalance)

Open in new window

0
Comment
Question by:vwalla
2 Comments
 
LVL 1

Author Comment

by:vwalla
ID: 24071579
ok.  I removed Optimistic concurrency checking & it works.  Still would like to know exactly why this would happen.
0
 
LVL 57

Accepted Solution

by:
Raja Jegan R earned 500 total points
ID: 24075505
Your UPDATE query involves lots of where conditions which will take more time to filter out your required records.
To make the UPDATE query perform faster:
1. You can make the transaction bound for that UPDATE query to be smaller.
2. Appropriate INDEX to reduce the UPDATE queries time.

Above steps will bring down your Concurrency related issues and obviously Deadlocks.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Restrict result set 1 34
Syntax Error 2 44
SQL Query with Sum and Detail rows 2 40
VB6 ListBox Question 4 32
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now