Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Field name is valid, but getting an "Item cannot be found.." error

Reply
Thread Tools

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

 
 
J. Muenchbourg
Guest
Posts: n/a
 
      09-25-2003
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!
 
Reply With Quote
 
 
 
 
WIlliam Morris
Guest
Posts: n/a
 
      09-25-2003

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" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> 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!



 
Reply With Quote
 
 
 
 
Bob Barrows
Guest
Posts: n/a
 
      09-25-2003
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


 
Reply With Quote
 
Aaron Bertrand [MVP]
Guest
Posts: n/a
 
      09-26-2003
> 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



 
Reply With Quote
 
Bob Barrows
Guest
Posts: n/a
 
      09-26-2003
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 ...


 
Reply With Quote
 
Aaron Bertrand [MVP]
Guest
Posts: n/a
 
      09-27-2003
> Hmmm - that's what I said ...

The newsgroups were pretty wacky, I actually didn't see your response until
I reset my group...


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
javascript validation for a not required field, field is onlyrequired if another field has a value jr Javascript 3 07-08-2010 10:33 AM
1.Enter space bar for field names and save the field.The field shoud not get saved and an alert should be there as"Space bars are not allowed" Sound Javascript 2 09-28-2006 02:43 PM
Read form "name" attribute when it contains form field with name "name" Pavils Jurjans Javascript 3 03-18-2005 01:39 PM
Request.Form("Field Name") Versus Request.QueryString("Field Name") John Davis ASP General 2 08-18-2003 05:00 AM
concatenate in Javascript function? simple field validation funciton not working - needs to concat field name with object NotGiven Javascript 7 07-24-2003 11:44 AM



Advertisments