Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21096

Error while my program is updating an sql table and another makes a change

$
0
0
I have a program that updates data in a web sql table. If a customer makes a purchase while the update is running, it affects the table causing a :
'Row cannot be located for updating. Some values may have been changed since it was last read.'

Can anyone tell me how I can change the commands so that a simultaneous change does not cause this? Someone mentioned going pessimistic instead of optimistic, but that was no help.


Code:

CurrentRecord = 0
If updateUPC.State = 1 Then updateUPC.Close
updateUPC.Open "Select * from isc_products ", con, adOpenStatic, adLockPessimistic
TotalRecords = updateUPC.RecordCount

Do While Not updateUPC.EOF
CurrentRecord = CurrentRecord + 1
TrackStock = updateUPC!prodinvtrack        'How is inventory Tracked?
Text1.Text = updateUPC!prodname
If TrackStock = 1 And updateUPC!prodcode <> "" Then          'Stock Is tracked by Item

If getUPC.State = 1 Then getUPC.Close
getUPC.Open "Select * from ItemInventory where ItemNumber = " & updateUPC!prodcode & "", adocon, adOpenStatic, adLockPessimistic

If getUPC.RecordCount <= 0 Then
Else
updateUPC!prodcurrentinv = getUPC!QuantityOnHand
updateUPC!UPC = getUPC!UPC
updateUPC.Update
Text2.Text = updateUPC!prodcurrentinv
If updateUPC!prodcurrentinv <= 0 Then
        updateUPC!prodvisible = 0
Else
        updateUPC!prodvisible = 1
End If
End If
Text3.Text = CurrentRecord & " of " & TotalRecords
Form1.Refresh

End If
updateUPC.MoveNext
Loop


Viewing all articles
Browse latest Browse all 21096

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>