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.

skyler99Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

 
jmar_clickCommented:
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")
0
 
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.

0
 
skyler99Author Commented:
This is an Access database 2000.  

I just try this.
 
response.write("<option value=""" & rs(0).value & """>") ...it works fine.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
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...
0

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
 
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
0
 
lojk.Net and Infrastructure ConsultantCommented:
I feel that i had offered most contribution but @ 25 points, really not that fussed.

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.