[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 566
  • Last Modified:

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

I know you guys have seen this error message before; Most of the field names have a space between them.  For Example: Job id, add no, telf no... etc.  I don't know how to define them on this statement:

response.write("<option value=""" & rs("job id") & """>")

I've already tried to put [] around "job id", also I removed the quotes around it  but it doesn't work.  Do you have any other ideas??

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

  • 4
1 Solution
field names should never conatin spaces, the database system should have trown error when the table was being made. Unless job id is an alias for a field, but even that should have an underscorel.

Try referencing it with rs("job")
lojk.Net and Infrastructure ConsultantCommented:
jmar is correct, field names should never contain spaces and most tech-types will turn green/purple if they see it (although it is technically valid in many DBs, MS Access immediatley springs to mind but query via DAO/ADO/.NET wil usually require the field wrapped in square brackets when referencing)

If you must Separate words in a field use an underscore '_' character but preferably do it Correctly 'JobID' or 'EmployeeName'.

However in this case one or more of these solutions may work but most likely the third one

response.write("<option value=""" & rs("[job id]") & """>")
response.write("<option value=""" & rs("job id").value & """>")

response.write("<option value=""" & rs("[job id]").value & """>")

in your example you are actually returning the field *object* rather than the *value* of the field.

skyler99Author Commented:
This is an Access database 2000.  

I just try this.
response.write("<option value=""" & rs(0).value & """>") ...it works fine.
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

lojk.Net and Infrastructure ConsultantCommented:
From your comment i would say that my second suggestion should work

can you post the query used to populate the rs? are you sure that 'job id' is a valid field within the query?
for t=0 to rs.fields.count
reponse.write "<br>"  & rs(t).name & "<br>"
next t

that will tell you exactly what the field name is at the time of query. Also if you are doing a

Select * from Table

i would suggest doing a

select [Table]. [Field 1] as FieldAlias1, [Table].[Field 2] as FieldAlias2 ... from Table

then queryying rs("FieldAlias1").value, that really should work...
lojk.Net and Infrastructure ConsultantCommented:
oops that should obviously say....

for t=0 to rs.fields.count -1
reponse.write "<br>"  & rs(t).name & "<br>"
next t
lojk.Net and Infrastructure ConsultantCommented:
I feel that i had offered most contribution but @ 25 points, really not that fussed.


Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now