Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Multiple-step OLE DB operation generated errors


Message #1 by dirosky@h... on Tue, 19 Nov 2002 12:50:40
This piece of code works fine in access but gives error:

Microsoft OLE DB Provider for SQL Server (0x80040E21)
Multiple-step OLE DB operation generated errors. Check each OLE DB status 
value, if available. No work was done. 


Set objRS = Server.CreateObject ("ADODB.Recordset") 
	objRS.Open "PurchaseOrder", objConn3, adOpenStatic, 
adLockOptimistic, adCmdTable 

	objRS.MoveLast
	intIDForNewRecord = objRS("PONO") + 1

	objRS.AddNew           ' add a new record
	objRS("PONO") = intIDForNewRecord   -- (ERROR LINE)
	objRS("CreatedBy") = strName

I have checked the filed size and it should be fine.

Any ideas?

Dirosky

Ken, I have tried everything on 
http://www.adopenstatic.com/faq/80040e21.asp
Message #2 by Imar@S... on Tue, 19 Nov 2002 17:15:54
Hi there,

Did you assign values for the enums like 
adOpenStatic etc?

If they don't have a value, you are passing 0 (adOpenForwardOnly) which 
will give you a recordset that doesn't support AddNew.....

HtH

Imar


> This piece of code works fine in access but gives error:

> Microsoft OLE DB Provider for SQL Server (0x80040E21)
M> ultiple-step OLE DB operation generated errors. Check each OLE DB 
status 
v> alue, if available. No work was done. 

> 
S> et objRS = Server.CreateObject ("ADODB.Recordset") 
	> objRS.Open "PurchaseOrder", objConn3, adOpenStatic, 
a> dLockOptimistic, adCmdTable 

> 	objRS.MoveLast
	> intIDForNewRecord = objRS("PONO") + 1

> 	objRS.AddNew           ' add a new record
	> objRS("PONO") = intIDForNewRecord   -- (ERROR LINE)
	> objRS("CreatedBy") = strName

> I have checked the filed size and it should be fine.

> Any ideas?

> Dirosky

> Ken, I have tried everything on 
h> ttp://www.adopenstatic.com/faq/80040e21.asp
Message #3 by "Drew, Ron" <RDrew@B...> on Tue, 19 Nov 2002 14:44:24 -0500
Don't need to movelast on an insert...I use...

Dim iRecordAdded      ' Id of added record
Dim objRecordset
Set objRecordset =3D Server.CreateObject("ADODB.Recordset")
objRecordset.Open strSQL, DB_CONNECTIONSTRING, adOpenKeyset,
adLockPessimistic, adCmdText
objRecordset.AddNew
.....
.....
objRecordset.Fields("date_time_field") =3D Now()
objRecordset.Update
' Get the DB assigned ID of the record we just added.
iRecordAdded =3D objRecordset.Fields("id").Value
' Tell people which record we added.
Response.Write "Record id " & iRecordAdded & " added!"
'then close the recordset

-----Original Message-----
From: dirosky@h... [mailto:dirosky@h...]
Sent: Tuesday, November 19, 2002 7:51 AM
To: ASP Web HowTo
Subject: [asp_web_howto] Multiple-step OLE DB operation generated errors



  Return to Index