473,657 Members | 2,397 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Item cannot be found in the collection corresponding to the requested name or ordinal

CJM
I'm running a stored procedure that inserts a record into a table then
returns the Identity field value. I've done this kind of thing plenty of
times in the past, but I'm obviously doing something wrong this time..

I've tested the Stored Proc in QA and it works fine. The SQL code runs OK in
ASP (iAffected = 1 which shows the record is inserted), but when I try to
query the resulting recordset, I get an error:

"Item cannot be found in the collection corresponding to the requested name
or ordinal. "

I'm sure this is something simple, but having just come back off 3 weeks
leave, my brain isn't yet up to speed...

Thanks

Chris

Code snippets:

ASP -

sConn = Application("DB ")
Set oConn = Server.CreateOb ject("ADODB.Con nection")

oConn.Open sConn

If Request.Form("N ext") <> "" Then
sSQL = "Exec S2_AddNewRFQ_Cu stDets '" & _
FilterSQL(Reque st.Form("Custom erID")) & "', '" & _
FilterSQL(Reque st.Form("Custom erName")) & "', '" & _
FilterSQL(Reque st.Form("Contac t")) & "', '" & _
FilterSQL(Reque st.Form("TelNo" )) & "', '" & _
FilterSQL(Reque st.Form("FaxNo" )) & "', '" & _
FilterSQL(Reque st.Form("Email" )) & "', '" & _
Session("UID") & "'"

Set rsRFQ = oConn.Execute(s SQL, iAffected)

'response.Write iAffected

iRFQ = rsRFQ("QuoteID" )
If iRFQ > 0 Then
Response.Redire ct "newrfq2.asp?id =" & iRFQ
Else
'error!
End if
End If

Stored Proc -

SET QUOTED_IDENTIFI ER ON
GO
SET ANSI_NULLS ON
GO

ALTER Proc S2_AddNewRFQ_Cu stDets
@CustomerID varchar(15),
@CustomerName varchar(50),
@Contact varchar(30),
@TelNo varchar(20),
@FaxNo varchar(20),
@Email varchar(50),
@Username varchar(20)
As

Insert into QuoteHeader
(CustomerID, CustomerName, ContactName, TelNo, FaxNo, Email, Originator,
LoggedDate, ExpirationDate, AssignedTo)
Values
(@CustomerID, @CustomerName, @Contact, @TelNo, @FaxNo, @Email, @Username,
dbo.DateValue(G etDate()), dbo.DateValue(D ateAdd(dd, 30, GetDate())),
@Username)

Select Scope_Identity( ) as QuoteID

GO

SET QUOTED_IDENTIFI ER OFF
GO
SET ANSI_NULLS ON
GO
Jul 21 '05 #1
2 22803
You need to SET NOCOUNT ON in your procedure.

CJM wrote:
I'm running a stored procedure that inserts a record into a table then
returns the Identity field value. I've done this kind of thing plenty
of times in the past, but I'm obviously doing something wrong this
time..
I've tested the Stored Proc in QA and it works fine. The SQL code
runs OK in ASP (iAffected = 1 which shows the record is inserted),
but when I try to query the resulting recordset, I get an error:

"Item cannot be found in the collection corresponding to the
requested name or ordinal. "

I'm sure this is something simple, but having just come back off 3
weeks leave, my brain isn't yet up to speed...

Thanks

Chris

Code snippets:

ASP -

sConn = Application("DB ")
Set oConn = Server.CreateOb ject("ADODB.Con nection")

oConn.Open sConn

If Request.Form("N ext") <> "" Then
sSQL = "Exec S2_AddNewRFQ_Cu stDets '" & _
FilterSQL(Reque st.Form("Custom erID")) & "', '" & _
FilterSQL(Reque st.Form("Custom erName")) & "', '" & _
FilterSQL(Reque st.Form("Contac t")) & "', '" & _
FilterSQL(Reque st.Form("TelNo" )) & "', '" & _
FilterSQL(Reque st.Form("FaxNo" )) & "', '" & _
FilterSQL(Reque st.Form("Email" )) & "', '" & _
Session("UID") & "'"

Set rsRFQ = oConn.Execute(s SQL, iAffected)

'response.Write iAffected

iRFQ = rsRFQ("QuoteID" )
If iRFQ > 0 Then
Response.Redire ct "newrfq2.asp?id =" & iRFQ
Else
'error!
End if
End If

Stored Proc -

SET QUOTED_IDENTIFI ER ON
GO
SET ANSI_NULLS ON
GO

ALTER Proc S2_AddNewRFQ_Cu stDets
@CustomerID varchar(15),
@CustomerName varchar(50),
@Contact varchar(30),
@TelNo varchar(20),
@FaxNo varchar(20),
@Email varchar(50),
@Username varchar(20)
As

Insert into QuoteHeader
(CustomerID, CustomerName, ContactName, TelNo, FaxNo, Email,
Originator, LoggedDate, ExpirationDate, AssignedTo)
Values
(@CustomerID, @CustomerName, @Contact, @TelNo, @FaxNo, @Email,
@Username, dbo.DateValue(G etDate()), dbo.DateValue(D ateAdd(dd, 30,
GetDate())), @Username)

Select Scope_Identity( ) as QuoteID

GO

SET QUOTED_IDENTIFI ER OFF
GO
SET ANSI_NULLS ON
GO


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 21 '05 #2
CJM
Ah... That's right...

Thanks Bob

Chris

"Bob Barrows [MVP]" <re******@NOyah oo.SPAMcom> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
You need to SET NOCOUNT ON in your procedure.

Jul 21 '05 #3

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

Similar topics

5
9393
by: J. Muenchbourg | last post by:
The field name 'articleid', which is an identity/primary key , is not being recognized in my recordset as I get an " Item cannot be found in the collection corresponding to the requested name or ordinal" error with the following- the line number that the error message points to is on my response.write for the rsid("articleID") : dim sqlid,rsid sqlid = "SELECT max(ArticleID) from tblarticles"
4
3472
by: Dthmtl | last post by:
I know what this error is, all fieldnames have been verified and reverified. Not sure why it is happening. Here is the SQL statement strSQL = "SELECT Problems.TicketNumber, Activity, ActDate FROM Problems LEFT JOIN Resolutions ON Problems.TicketNumber = Resolutions.TicketNumber WHERE Problems.TicketNumber = " & Ticket & " ORDER BY ActDate DESC;" <td><% = rs("Problems.TicketNumber") %></td>
8
5463
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- Hello, I have a very simple problem but cannot seem to figure it out. I have a very simple php script that sends a test email to myself. When I debug it in PHP designer, it works with no problems, I get the test email. If
9
8010
by: Gerald Lightsey | last post by:
I am doing some work that involves automating MS MapPoint 2002. The object model is documented in the context of Visual Basic 6.0. A typical example follows. 'Output first result of find search Set objFindResults = objApp.ActiveMap.FindAddressResults("One Microsoft Way", "Redmond", , "WA", , geoCountryUnitedStates) MsgBox "The first item in the find list is: " _ + objFindResults.Item(1).Name
18
4728
by: JohnR | last post by:
From reading the documentation, this should be a relatively easy thing. I have an arraylist of custom class instances which I want to search with an"indexof" where I'm passing an instance if the class where only the "searched" property has a value. I expected to get the index into the arraylist where I could then get the entire class instance. However, the 'indexof' is never calling my overloaded, overrides Equals method. Here is the...
2
1696
by: indhu | last post by:
Hi its not working, i want only distinct record. here its repeated records coming. accdb = "SELECT DISTINCT sequence FROM scene WHERE sceneid = '" & myquery & "' " and when i select the first record in combo it says run time error: item cannot be found in teh collection corresponding to the requested name or ordinal. but not for second records
2
1768
by: anson | last post by:
this code is an example code of TPOP, i type them and can be compiled... but when give some input , it getting segment fault .... i observed that when the build() initial the word table ... it invoke next_word(in the book its name is new() )and invoke the routine lookup ...but it cannot lookup anything ....and return NULL. where goes wrong? below is the code...
2
4255
by: Sticksboy | last post by:
I keep getting this error message - Item cant be found in the collection corresponding to the requested name or ordinal I dont understand what it means to be honest. I am trying to get the code I have written to fill the textboxes on the form, I have been using Me.Controls on another form and this works fine, but with me doing slightly different in the way the form opens it doesnt seem to like it. Can anyone point out where I have gone...
8
6292
by: charli | last post by:
Error 3265, "Item cannot be found in the collection corresponding to the requested name or ordinal" code programatically opens a query using ADOX and changed the sql Dim cat As New ADOX.Catalog Dim cmd As New ADODB.Command cat.ActiveConnection = CurrentProject.Connection Set cmd = cat.Procedures("qryLostCostCodes").Command 'opens existing query to edit
0
8402
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8315
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8829
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8734
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8608
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4164
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4323
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2733
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1627
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.