Link to home
Start Free TrialLog in
Avatar of GabrielCucut
GabrielCucutFlag for Spain

asked on

Error 3265 accessing MS Access Database from an ASP page: Item cannot be found in the collection corresponding to the requested name or ordinal

I have the following error accessing from an ASP page to a MS Access Database without security passwords.

Error 3265
Item cannot be found in the collection corresponding to the requested name or ordinal

· I have checked security permissions and seem to be all right.

I have tried the following connection methods and none works:

set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & "C:\Inetpub\wwwroot\folder\database.mdb")

and

set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & "C:\Inetpub\wwwroot\folder\database.mdb"

I have found some articles on Microsoft talking about a ressolution like:
"Set the object's ParentCatalog property to a valid Catalog object,
-or-
make sure the Parent Catalog is associated with a valid ADO Connection Object. "

but couldn't find how. Please help. Thanks.
Avatar of Thogek
Thogek
Flag of United States of America image

What line of code is this error raising on?  Offhand, it doesn't sound like a problem with the initial database connection, but more with the accessing of a data field after a query has been made.  (Unless I completely misread something...)
Does the error arise on the oConn.Open call, or later...?
Avatar of GabrielCucut

ASKER

It looks like the error was not on the open, but when I migrated some databases to a different database some columns changed format. I am investigating it now. I will tell you in a moment.
Avatar of fritz_the_blank
I think that Thogek is correct--most often when I see that error, the sql select or recordset points to a field that does not exist in the table.

To make sure however, please try this page:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>

<BODY>
<%
dim objConnection, strDataPath
strDataPath = "C:\Inetpub\wwwroot\folder\database.mdb"
set objConnection=Server.CreateObject("ADODB.Connection")
strConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;"_
                  & " Data Source= " & strDataPath & ";"_
                  & " Mode=Share Deny None;User Id=admin;PASSWORD=;"

objConnection.ConnectionTimeout = 15
objConnection.CommandTimeout =  10
objConnection.Mode = 3 'adModeReadWrite
if objConnection.state = 0 then
      objConnection.Open strConnectString
end if

Response.write("The Connection State is: " & objConnection.State)

%>
</BODY>
</HTML>
SOLUTION
Avatar of Thogek
Thogek
Flag of United States of America 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
It looks like it is happenning something similar to what you are saying.

After every connection there is an error check and a collector for all errors of different connections.

Which property of the recordset can I use to obtain the name of teh adodb connection that is failing?
Why do you have so many connections? Is there more than one database?

FtB
Avatar of jitganguly
jitganguly

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

This means you are refering some columns but didn't pull it from SQL or Stored PRocedure

So, check your SQL or Sp and make sure you are usign the correct name

If you have spaces or between column names use braces in your SQL statement like [Party Code]

and in recordset object, directly use it like rs("Party Code")
@jitganguly --

Thogek has already made that observation above in his first comment.

FtB
To review, here is where we are:

1) Thogek observes that this error usually results from pointing at a non-existant field in the table or recordset
2) I concurred that is most often the case, but since there was some concern that the connection was not being made, I offered a simple test page. If this worked, then we could be reasonably sure that Thogek had it correct.

FtB
fritz_the_blank

I have tried the code and pasted it in an html file calling it check.html and when run only a blank page is loaded (all white background).

You have to paste it into an .asp file for it to work.

FtB
Ok, I put it as check.asp and says the connection state is 1.

How can I use it for the Microsoft SQL server being a system-DSN ?
Okay, let's stop there and make clear that you are able to make a connection, and that is a good start!!!

Now, I am a little confused. Is this question about a problem grabbing data from an Access database or about making connections in general? If the former, we should try to get your data out and isolate why you were getting that error. If the latter, then we need to work on a new connection string.

FtB

Finally: The problem is connecting to an SQL Server table.

I think I have found where the problem is:

I have migrated an Oracle database to SQL Server and changed a "to_char( end_date, "dd/mm/yyyy")" function into "convert(char(10), end_date, 103)" and I think the problem is the first time I use this CONVERT function.

So, probably the error has more to do with SQL server than ASP. Anyway, I am using ADODB.Recordset, should I try another connection mechanism to use this transact-SQL-specific functions?
ASKER CERTIFIED SOLUTION
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
However, I am still not sure how the above relates to your original error...

FtB
Thanks, I have found it. The problem was:

Using CONVERT( ... end_date ...) the resulting variable is a "Expr1".
Later in the ASP the program wants to access the "end_date" column in the recordset.

I am not an Oracle expert, but maybe the TO_CHAR function does not need to put "AS END_DATE" after the function, and it seems that SQL Server does need that or either it puts an Expr1, Expr2, ... names.

(Thanks a lot, I think it is fair to concede some point to Thogek and the rest for you.)
So, basically, the field names you used in your code did not match the names of the columns returned by the query?  (E.g., "end_date" vs. "Expr1".)
I am happy to have helped but am curious, why the grade of B?

FtB
I just thought that grade Excellent was when a very-very difficult question is answered really straight forward. This was not the case, maybe because I didn't provide apropriate information to target the problem, however I still think that an Excellent is when an answer has been extremely valuable.

thanks, Gabriel
Fair enough. Just keep in mind that everyone who answers questions here does so on a voluntary basis without compensation, and for most of us, the points and the grade are a token of appreciation for time and effort spent. Moreover, in this instance, the answer had very little to do with the question posed. If you would like straightforward answers, be sure to take a lot of time to craft your question carefully. Otherwise, there is no way, other than sheer luck, for us to provide you with that straight forward response that you are looking for (providing that such an answer even exists!).

FtB