Link to home
Start Free TrialLog in
Avatar of skyler99
skyler99

asked on

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.

Avatar of jmar_click
jmar_click

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")
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.

Avatar of skyler99

ASKER

This is an Access database 2000.  

I just try this.
 
response.write("<option value=""" & rs(0).value & """>") ...it works fine.
ASKER CERTIFIED SOLUTION
Avatar of lojk
lojk
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
oops that should obviously say....

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