Results 1 to 9 of 9
  1. #1
    Join Date
    Mar 2004
    Posts
    7

    Unanswered: Item cannot be found in the collection corresponding to the requested name or ordinal

    Hi all,

    My problem:
    When I use the following code, I get "unspecified error". And when I debug the code using "response.write", I get "ADODB.Recordset (0x800A0CC1)Item cannot be found in the collection corresponding to the requested name or ordinal."

    The code is simply trying to get a single data from a form and write it down to the access database. I'm pretty sure that all the spellings are correct. Anyway, here is the code:

    -----------------------------------------------------------
    set conn=Server.CreateObject("ADODB.Connection")
    conn.Provider="Microsoft.Jet.OLEDB.4.0"
    conn.Open Server.MapPath("../../../db/denizbaris.mdb")
    set Katalog=Server.CreateObject("ADODB.recordset")

    SQL = "Select * from CATALOG where ID = "& Request("ID")

    conn.execute (SQL)

    Katalog("COMPANY_ID") = Request("COMPANY_ID")

    Katalog.Update
    Katalog.Close
    Set Katalog = Nothing
    -----------------------------------------------------------

    Any help ?
    thanx,
    Baris

  2. #2
    Join Date
    Jan 2003
    Location
    New York
    Posts
    160
    SQL = "Select * from CATALOG where ID = "& Request("ID")
    should be
    SQL = "Select * from CATALOG where ID = '"& Request("ID") & "'"

    put quotes around it
    Beyond Limitation

  3. #3
    Join Date
    Mar 2004
    Posts
    7
    thanx,

    Got "(0x80004005) Unspecified error" again.

    And when I try debugging with response.write, "I again get Item cannot be found..." again.

    Also tried this:
    Set Katalog = conn.execute(SQL)
    and again I got "unspecified error"

    I'm pretty sure that I gave all the permissions to all the folders as unspecified error is a security issue. But it won't work also.

    totally stuck-up...

    thanx,
    Baris

  4. #4
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    the error you are getting generally means it can't find the field you are refering to....

    try this to get more info on what is happening...

    Code:
    on error resume next
    
    set conn=Server.CreateObject("ADODB.Connection")
    conn.Provider="Microsoft.Jet.OLEDB.4.0"
    conn.Open Server.MapPath("../../../db/denizbaris.mdb")
    set Katalog=Server.CreateObject("ADODB.recordset")
    
    SQL = "Select * from CATALOG where ID = "& Request("ID")
    
    conn.execute (SQL)
    
    if katalog.eof then
      response.write "No records found matching the ID "& Request("ID")
    end if
    
    for each field in katalog.fields
      response.write "Fieldname: " & field.Name & "<br>"
    next
    
    Katalog("COMPANY_ID") = Request("COMPANY_ID")
    
    Katalog.Update
    Katalog.Close
    Set Katalog = Nothing
    the first added bit will let you know if any records are coming back.

    the second bit should (assuming my guess at the methods etc are correct) loop through the fields in the recordset and print out the field names. this will let you ensure you are looking for the right field in your recordset.

    hth

  5. #5
    Join Date
    Mar 2004
    Posts
    7
    Yo rokslide thanx,

    I still got the "unspecified error".
    This time on debugging with the response.write, I got:
    "Operation is not allowed when the object is closed"
    on line 9, which is the one you've added: "for each field in katalog.fields".

    this is getting more confusing... how the hell it gets closed when I do not close it...

    Anyway, I should also mention that all the site is going well with zero problems, as well as opening, retrieving and writing data to any and all tables and fields, EXCEPT that CATALOG table. I can retrieve any data from it, but WRITING on it (CATALOG table) is somehow impossible.

    my 2 cents
    Baris

  6. #6
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    errgghhhh,... of course....

    you have....
    Code:
    conn.execute (SQL)
    Katalog("COMPANY_ID") = Request("COMPANY_ID")
    you should have
    Code:
    Katalog = conn.execute (SQL)
    Katalog("COMPANY_ID") = Request("COMPANY_ID")
    you are not actually setting your recordset to the response from the execution of the command.

  7. #7
    Join Date
    Mar 2004
    Posts
    7
    Tried it also. And the result is: "unspecified error" (shit)

    I'm now using this code:


    Function ConConnect()

    Set Conn = Server.CreateObject("ADODB.Connection")

    Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Inetpub\wwwroot\rehber\db\denizbaris.mdb ;"

    End Function

    ConConnect()

    Set Katalog = Server.Createobject("Adodb.Recordset")
    SQL = "Select * from CATALOG where ID = "& Request("ID")
    Katalog.Open SQL, conn, 1, 3 '<---- UNSPECIFIED ERROR AGAIN


    I'm using this one this time because I've used the same code for all the complete site. As I said before I got no errors until now. just writing something in that CATALOG table is impossible. Maybe I've done something wrong in MS Access while creating the table ?

    hell...

    peace
    Baris

  8. #8
    Join Date
    Mar 2004
    Posts
    7

    RESERVED WORD

    It took me a week to handle it, EVEN tho I knew that there were some "RESERVED WORD"s

    I tried 56432943289 variations of connecting to the database but somehow it was impossible. Here is that's why:

    Remember the table that I can retrieve info from but can't write anything in it. Name of that table was "CATALOG"

    CATALOG is a reserved word for ODBC !

    So then, How can it be possible to retrieve info from a table named mistakenly with a reserved word ? I never thought that it maybe a reserved word, B'couse the table is working when retrieving info. That idea faked me toooooooo good... (So do you also tho)

    Got too much headace after this mind-blowing week. Gonna have some sleep now...

    check all the reserved words here if you also need:
    http://www.aspfaq.com/show.asp?id=2080

    Thanx everyone,
    peace,
    Baris

  9. #9
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    Errrr,... you're uses oledb, not odbc.... either way, you are probably right...

    In MS SQL you could put square brackets around the word and that should see you right,.. not sure with Access....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •