471,089 Members | 1,598 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Field name is valid, but getting an "Item cannot be found.." error

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"
Set rsid = Server.CreateObject("ADODB.Recordset")
rsid.Open sqlid,sqlc,3
response.write rsid("ArticleID")

???
Muench

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #1
5 9275

Two things to check: 1. is the connection valid, and state = 1? 2. Is the
recordset state = 1?
--
William Morris
Product Development, Seritas LLC
"J. Muenchbourg" <jo*****@canada.com> wrote in message
news:#7**************@TK2MSFTNGP10.phx.gbl...
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"
Set rsid = Server.CreateObject("ADODB.Recordset")
rsid.Open sqlid,sqlc,3
response.write rsid("ArticleID")

???
Muench

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 19 '05 #2
J. Muenchbourg wrote:
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"
Set rsid = Server.CreateObject("ADODB.Recordset")
rsid.Open sqlid,sqlc,3
response.write rsid("ArticleID")

The problem is that this query does not return a column with the name
ArticleID. It's returning the result of an expression. The column is getting
some default name. It may be "Expr1" which is what you would see as the
column title if you ran this query in Access.

You need to either:
a) refer to the column by its ordinal position: response.write rsid(0).value
or
b) Use a column alias:
sqlid = "SELECT max(ArticleID) As MaxArticleID from tblarticles"
....
response.write rsid("MaxArticleID")

I prefer a) myself.

HTH,
Bob Barrows
Jul 19 '05 #3
> sqlid = "SELECT max(ArticleID) from tblarticles"

No, the /column/ name is not valid. Notice you did not ask for ArticleID
here, you asked for max(ArticleID).

http://www.aspfaq.com/2159

Jul 19 '05 #4
Aaron Bertrand [MVP] wrote:
sqlid = "SELECT max(ArticleID) from tblarticles"


No, the /column/ name is not valid. Notice you did not ask for
ArticleID here, you asked for max(ArticleID).

http://www.aspfaq.com/2159


Hmmm - that's what I said ... ;-)
Jul 19 '05 #5
> Hmmm - that's what I said ... ;-)

The newsgroups were pretty wacky, I actually didn't see your response until
I reset my group...
Jul 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by hjyn | last post: by
reply views Thread by Özden Irmak | last post: by
13 posts views Thread by Jack MacRank | last post: by
3 posts views Thread by =?Utf-8?B?UGF1bCBQcmV3ZXR0?= | last post: by

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.