2
votes

The following works in Access;

SELECT Transactions.Date, Transactions.Time, Transactions.Direction,
           Transactions.TransactionNumber, Transactions.TransactionType,
           Transactions.Exception, Exceptions.ExceptionType
FROM Transactions LEFT JOIN Exceptions 
         ON  (Transactions.TransactionNumber = Exceptions.TransactionNumber)
         AND (Transactions.Date = Exceptions.Date) 
         AND (Transactions.TokenNumber = Exceptions.TokenNumber)
WHERE (((Transactions.Date)>=20120803) 
         AND ((Transactions.Direction)=-1) 
         AND ((Exceptions.ExceptionType) Not In (43,44,45,46) 
             OR (Exceptions.ExceptionType) Is Null) 
         AND ((Transactions.TokenNumber)=6605253))
ORDER BY Transactions.Date, Transactions.TransactionNumber;

But when done in ASP as below, I get error '80004005'

SELECT Transactions.Date, Transactions.Time, Transactions.Direction,
           Transactions.TransactionNumber, Transactions.TransactionType,
           Transactions.Exception, Exceptions.ExceptionType 
FROM Transactions LEFT JOIN Exceptions 
        ON Transactions.TransactionNumber = Exceptions.TransactionNumber 
    AND Transactions.Date = Exceptions.Date 
        AND Transactions.TokenNumber = Exceptions.TokenNumber 
WHERE Transactions.Direction = -1 
        AND (Exceptions.ExceptionType Not In (43,44,45,46) 
            OR Exceptions.ExceptionType Is Null)
        AND Transactions.TokenNumber= 6605253
        AND Transactions.Date >= 20120803 
ORDER BY Transactions.Date, Transactions.TransactionNumber

I removed some of the brackets by the way, thinking it would help, but it did not.

3
Are you sure it is the query? support.microsoft.com/kb/306345Fionnuala
Ah, I think it's something to do with Exception being a reserved word in Access. Remember I had this a few days ago and forgot about it.Ben Hamilton
Shouldn't date values be delimited with '#' in Jet queries, e.g. #20120803#?Tony
20120803 could not be an MS Access date, it is a number.Fionnuala
I do not think that Exception being a reserved word is the problem in this case. A reserved word is only a problem when it is not prefixed with the table name. For that matter, date and time are also reserved words.Fionnuala

3 Answers

2
votes

I agree with Remou's comment. 80004005 doesn't point at a bad query, I think it points at a data source name being wrong or a corrupt Access file.

I would check your connection string and verify that you can run a simple query before chasing this query.

2
votes

This was resolved by putting the word Exception in square brackets.

1
votes

MikeY is right. Make sure all of your IIS proceses have read/write (NTFS) permissions to the folder containing the database. Typically, that would be the IUSR_[machinename] account. Depending on which version of IIS you are using, it would be different. In IIS, have a look at which account the "Anonymous" user is mapped to.

For a quick-check, just set the folder to read/write for "Everyone". It has to be at the folder level, not just the file, because MSAccess needs to create/destroy a .LDB file for maintaining locks, etc.