Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 726
  • Last Modified:

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.
0
GabrielCucut
Asked:
GabrielCucut
  • 10
  • 7
  • 5
  • +1
2 Solutions
 
ThogekCommented:
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...)
0
 
ThogekCommented:
0
 
ThogekCommented:
Does the error arise on the oConn.Open call, or later...?
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
GabrielCucutAuthor Commented:
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.
0
 
fritz_the_blankCommented:
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>
0
 
ThogekCommented:
> when I migrated some databases to a different
> database some columns changed format

If any of your data columns changed name, make sure that the names you use in your code match the names of the columns in the data tables (as I believe Fritz is suggesting)...
0
 
GabrielCucutAuthor Commented:
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?
0
 
fritz_the_blankCommented:
Why do you have so many connections? Is there more than one database?

FtB
0
 
jitgangulyCommented:
>>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")
0
 
fritz_the_blankCommented:
@jitganguly --

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

FtB
0
 
fritz_the_blankCommented:
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
0
 
GabrielCucutAuthor Commented:
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).

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

FtB
0
 
GabrielCucutAuthor Commented:
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 ?
0
 
fritz_the_blankCommented:
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

0
 
GabrielCucutAuthor Commented:
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?
0
 
fritz_the_blankCommented:
Sure. The SQL connection string is very similar:

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

<BODY>
<%
dim objConnection
set objConnection=Server.CreateObject("ADODB.Connection")
strConnectString = "Provider=sqloledb;" & _
           "Data Source=myServerName;" & _
           "Initial Catalog=myDatabaseName;" & _
           "User Id=myUsername;" & _
           "Password=myPassword"
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>
0
 
fritz_the_blankCommented:
However, I am still not sure how the above relates to your original error...

FtB
0
 
GabrielCucutAuthor Commented:
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.)
0
 
ThogekCommented:
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".)
0
 
fritz_the_blankCommented:
I am happy to have helped but am curious, why the grade of B?

FtB
0
 
GabrielCucutAuthor Commented:
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
0
 
fritz_the_blankCommented:
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
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.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 10
  • 7
  • 5
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now