473,396 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ADODB.Recordset (0x800A0CC1) Error

Joe
I want to add a new record to database, and then retrives the @@IDENTITY value for this ne
added record, and the fields of this record. However, it has the following error on
line varNewID = objRS("NewMsgID"

ADODB.Recordset (0x800A0CC1
Item cannot be found in the collection corresponding to the requested name or ordinal

sqlStmt= "INSERT INTO AddressValidation "
& "(RequestXML, ResponseXML) "
& "VALUES ("
& "'" & strRequestXML & "'" & ","
& "'" & strResponseXML & "'" & ");

sqlStmt = sqlStmt & "SELECT @@IDENTITY AS NewMsgID;

Set objConn=Server.CreateObject("ADODB.Connection"
objConn.Open strConnec
Set objRS = objConn.Execute(sqlStmt
varNewID = objRS("NewMsgID") '<============= ERROR HERE!!
Response.Write "varNewID = " & varNewID & "<BR>
sqlStmt = sqlStmt & "SELECT * FROM AddressValidation WHERE AddressValidationID = " & "'" & varNewID & "'" & ";
Set objRS = objConn.Execute(sqlStmt
varXMLRequest = objRS("RequestXML"
varXMLRequest = objRS("ResponseXML"
Response.Write "varXMLRequest = " & varXMLRequest & "<BR>
Response.Write "varXMLRequest = " & varXMLRequest & "<BR>
objConn.Close(
Set objConn = Nothin
Set objRS = Nothing
Jul 19 '05 #1
6 8807
Joe wrote:
I want to add a new record to database,


What database?

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #2
joe
MS-SQL 2K
Jul 19 '05 #3
Add a "SET NOCOUNT ON;" just before your INSERT statement. The INSERT row
count is being returned, before the @@IDENTITY is, and hence the error.

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"Joe" <an*******@discussions.microsoft.com> wrote in message
news:BD**********************************@microsof t.com...
I want to add a new record to database, and then retrives the @@IDENTITY value for this new added record, and the fields of this record. However, it has the following error on line varNewID = objRS("NewMsgID")

ADODB.Recordset (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested name or ordinal.

sqlStmt= "INSERT INTO AddressValidation " _
& "(RequestXML, ResponseXML) " _
& "VALUES (" _
& "'" & strRequestXML & "'" & "," _
& "'" & strResponseXML & "'" & ");"

sqlStmt = sqlStmt & "SELECT @@IDENTITY AS NewMsgID;"

Set objConn=Server.CreateObject("ADODB.Connection")
objConn.Open strConnect
Set objRS = objConn.Execute(sqlStmt)
varNewID = objRS("NewMsgID") '<============= ERROR HERE!!!
Response.Write "varNewID = " & varNewID & "<BR>"
sqlStmt = sqlStmt & "SELECT * FROM AddressValidation WHERE AddressValidationID = " & "'" & varNewID & "'" & ";" Set objRS = objConn.Execute(sqlStmt)
varXMLRequest = objRS("RequestXML")
varXMLRequest = objRS("ResponseXML")
Response.Write "varXMLRequest = " & varXMLRequest & "<BR>"
Response.Write "varXMLRequest = " & varXMLRequest & "<BR>"
objConn.Close()
Set objConn = Nothing
Set objRS = Nothing

Jul 19 '05 #4
joe wrote:
MS-SQL 2K


OK, that means you are getting an extra recordset back containing the "x
records affected" informational message. To suppress that, add this:
sqlStmt= "SET NOCOUNT ON;" _
& "INSERT INTO AddressValidation " _
etc.

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #5
Usually implies that the field you requested is not in the table or
recordset or that the recordset has no records.

So .. I suspect that your *first* SQL statement is invalid - try it without
the SELECT @@IDENTITY or in the MSSQL Query Analyzer.

Chris.

"Joe" <an*******@discussions.microsoft.com> wrote in message
news:BD**********************************@microsof t.com...
I want to add a new record to database, and then retrives the @@IDENTITY
value for this new
added record, and the fields of this record. However, it has the following
error on
line varNewID = objRS("NewMsgID")

ADODB.Recordset (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested name
or ordinal.
sqlStmt= "INSERT INTO AddressValidation " _
& "(RequestXML, ResponseXML) " _
& "VALUES (" _
& "'" & strRequestXML & "'" & "," _
& "'" & strResponseXML & "'" & ");"

sqlStmt = sqlStmt & "SELECT @@IDENTITY AS NewMsgID;"

Set objConn=Server.CreateObject("ADODB.Connection")
objConn.Open strConnect
Set objRS = objConn.Execute(sqlStmt)
varNewID = objRS("NewMsgID") '<============= ERROR HERE!!!
Response.Write "varNewID = " & varNewID & "<BR>"
sqlStmt = sqlStmt & "SELECT * FROM AddressValidation WHERE
AddressValidationID = " & "'" & varNewID & "'" & ";"
Set objRS = objConn.Execute(sqlStmt)
varXMLRequest = objRS("RequestXML")
varXMLRequest = objRS("ResponseXML")
Response.Write "varXMLRequest = " & varXMLRequest & "<BR>"
Response.Write "varXMLRequest = " & varXMLRequest & "<BR>"
objConn.Close()
Set objConn = Nothing
Set objRS = Nothing
Jul 19 '05 #6
Forget that - I always forget about SET NOCOUNT ON!
BTW: With a *single connection instance* you can always do the SELECT
@@IDENTITY as a second SQL statement recordset request it's own right since
the IDENTITY value is specific to that connection and thus retained after
each INSERT until the connection is closed.

Chris.

"Chris Barber" <ch***@blue-canoe.co.uk.NOSPAM> wrote in message
news:ua*************@TK2MSFTNGP10.phx.gbl...
Usually implies that the field you requested is not in the table or
recordset or that the recordset has no records.

So .. I suspect that your *first* SQL statement is invalid - try it without
the SELECT @@IDENTITY or in the MSSQL Query Analyzer.

Chris.

"Joe" <an*******@discussions.microsoft.com> wrote in message
news:BD**********************************@microsof t.com...
I want to add a new record to database, and then retrives the @@IDENTITY
value for this new
added record, and the fields of this record. However, it has the following
error on
line varNewID = objRS("NewMsgID")

ADODB.Recordset (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested name
or ordinal.
sqlStmt= "INSERT INTO AddressValidation " _
& "(RequestXML, ResponseXML) " _
& "VALUES (" _
& "'" & strRequestXML & "'" & "," _
& "'" & strResponseXML & "'" & ");"

sqlStmt = sqlStmt & "SELECT @@IDENTITY AS NewMsgID;"

Set objConn=Server.CreateObject("ADODB.Connection")
objConn.Open strConnect
Set objRS = objConn.Execute(sqlStmt)
varNewID = objRS("NewMsgID") '<============= ERROR HERE!!!
Response.Write "varNewID = " & varNewID & "<BR>"
sqlStmt = sqlStmt & "SELECT * FROM AddressValidation WHERE
AddressValidationID = " & "'" & varNewID & "'" & ";"
Set objRS = objConn.Execute(sqlStmt)
varXMLRequest = objRS("RequestXML")
varXMLRequest = objRS("ResponseXML")
Response.Write "varXMLRequest = " & varXMLRequest & "<BR>"
Response.Write "varXMLRequest = " & varXMLRequest & "<BR>"
objConn.Close()
Set objConn = Nothing
Set objRS = Nothing

Jul 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Randi | last post by:
Hi all, I have this project to use the ADODB control to acces and manipulate the Access DB. I amd the mistake of first doing this project with just the data control. It worked fine with this...
0
by: elcc1958 | last post by:
I need to support a VB6 application that will be receiving disconnected ADODB.Recordset from out DotNet solution. Our dotnet solution deals with System.Data.DataTable. I need to populate a...
0
by: Dot Netizen | last post by:
I am having trouble passing an ADODB.Recordset from a VB6 application to a VB.Net class library using COM Interop. I am running this on XP SP2 with the .Net Framework 1.1 and MDAC 2.8 SP1. I've...
5
by: Simone | last post by:
Hello I hope you guys can help me. I am very new to ADO... I am creating a ADODB connection in a module and trying to access it from a command button in a form. Function fxEIDAssgn(plngEID As...
0
by: Andre Azevedo | last post by:
Hi all ! I've created a .net serviced component with only one method. This method receive an ADODB.Command object and execute it. The ADODB.Command object is created in the client process. (VB...
3
by: Yuk Tang | last post by:
I'm trying to grab the fieldnames and values from a recordset, but I'm getting errors. I have an idea what the error might come from, but I'm not sure how to correct it. I'm connecting to an...
7
by: boyleyc | last post by:
Hi all I have written a database in access and used ADODB recordsets all the way through. The only recordsets that are not ADODB are the listbox navigation code automatically generated by access...
3
by: dotnetdev1 | last post by:
Hi Friends, Wen I am rying to run my asp application....i am ending up with this following error... Error Type: ADODB.Recordset (0x800A0CC1) Item cannot be found in the...
1
by: Shiller | last post by:
Experts, I keep getting the following error message when accessing a web page: ADODB.Recordset (0x800A0CC1) Item cannot be found in the collection corresponding to the requested name or...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
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...

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.