Friday, March 9, 2012

Row Cannot be Located for Update Error

Can anyone offer any suggetions as to what could be causing this error
in my ASP. Please dont mind the newbie code, I'm still pretty green
at this:
*******ERROR*******
Microsoft Cursor Engine error '80040e38'
Row cannot be located for updating. Some values may have been changed
since it was last read.
-- ASP Code Causing the Trouble --
strSQL = "SELECT * FROM WorkLog WHERE QuoteID = ""eID&" And stepID
= "&eventID
'Create the Recordset object and run SQL statement
Set logRS = Server.CreateObject ("ADODB.Recordset")
logRS.CursorLocation = adUseClient
logRS.Open strSQL, objConn,, adLockOptimistic
logRS("Completed") = True
logRS("CompletedBy") = secID
logRS("DateComplete") = Date()
logRS.Update <--ERROR HERE
'-- Trigger On Effected Table --
CREATE TRIGGER UpdateNextDue ON [dbo].[WorkLog]
FOR UPDATE
AS
Declare @.logID int,
@.quoteID int,
@.stepnum int,
@.userID int,
@.stepID int
Alter Table WorkLog Disable Trigger All
Set @.logID = (Select Log_ID From Inserted)
Set @.quoteID =( Select QuoteID From WorkLog Where Log_ID = @.logID)
Set @.stepID = (Select stepID From WorkLog Where Log_ID = @.logID)
Set @.stepNum =( Select Max(StepNum) From WorkLog Where quoteID = @.quoteID And Completed = 1)
Set @.userID =( Select UserID From WorkLog Where quoteID = @.quoteID And
StepNum = @.stepnum + 1)
If @.stepID <> '65'
Begin
Update WorkLog
Set NextDue = 1
Where QuoteID = @.quoteID And
StepNum = @.stepnum + 1
Alter Table Quotes Disable Trigger All
Update Quotes
Set NextStep = @.userID
Where @.quoteID = quoteID
Alter Table Quotes Enable Trigger All
End
Alter Table WorkLog Enable Trigger AllHow about instead of opening up a recordset, you just execute an UPDATE
statement?
objConn.Execute("UPDATE ... WHERE ...")
The error sounds like you don't have a primary key, or there's not enough
information to identify the row based on the primary key. Since you use
SELECT *, I'm assuming the former. Are you familiar with primary keys? Is
it possible that there is more than one row WHERE QuoteID = ""eID&" And
stepID
= "&eventID ?
--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"belacyrf" <bela@.webnet-x.com> wrote in message
news:d0e7d44f.0405141126.20601f4@.posting.google.com...
> Can anyone offer any suggetions as to what could be causing this error
> in my ASP. Please dont mind the newbie code, I'm still pretty green
> at this:
> *******ERROR*******
> Microsoft Cursor Engine error '80040e38'
> Row cannot be located for updating. Some values may have been changed
> since it was last read.
> -- ASP Code Causing the Trouble --
> strSQL = "SELECT * FROM WorkLog WHERE QuoteID = ""eID&" And stepID
> = "&eventID
> 'Create the Recordset object and run SQL statement
> Set logRS = Server.CreateObject ("ADODB.Recordset")
> logRS.CursorLocation = adUseClient
> logRS.Open strSQL, objConn,, adLockOptimistic
> logRS("Completed") = True
> logRS("CompletedBy") = secID
> logRS("DateComplete") = Date()
> logRS.Update <--ERROR HERE
> '-- Trigger On Effected Table --
> CREATE TRIGGER UpdateNextDue ON [dbo].[WorkLog]
> FOR UPDATE
> AS
> Declare @.logID int,
> @.quoteID int,
> @.stepnum int,
> @.userID int,
> @.stepID int
> Alter Table WorkLog Disable Trigger All
> Set @.logID = (Select Log_ID From Inserted)
> Set @.quoteID =( Select QuoteID From WorkLog Where Log_ID = @.logID)
> Set @.stepID = (Select stepID From WorkLog Where Log_ID = @.logID)
> Set @.stepNum =( Select Max(StepNum) From WorkLog Where quoteID => @.quoteID And Completed = 1)
> Set @.userID =( Select UserID From WorkLog Where quoteID = @.quoteID And
> StepNum = @.stepnum + 1)
> If @.stepID <> '65'
> Begin
> Update WorkLog
> Set NextDue = 1
> Where QuoteID = @.quoteID And
> StepNum = @.stepnum + 1
> Alter Table Quotes Disable Trigger All
> Update Quotes
> Set NextStep = @.userID
> Where @.quoteID = quoteID
> Alter Table Quotes Enable Trigger All
> End
> Alter Table WorkLog Enable Trigger All

No comments:

Post a Comment