Error when calling the OleDbDataAdapter.Fill() method

  • Thread starter Thread starter Nathan Sokalski
  • Start date Start date
N

Nathan Sokalski

I am recieving the following error message when I call the
System.Data.OleDb.OleDbDataAdapter.Fill() method in ASP.NET/VB.NET:


IErrorInfo.GetDescription failed with E_FAIL(0x80004005).


I have looked for help on this error on the web, and every site I found said
it is caused by using a keyword as a fieldname in my database. However, I
have checked and am pretty sure that none of my fieldnames are keywords.
Here is the SQL statement I am executing (I am using Microsoft Access as my
database):


SELECT headline,url,summary,updated FROM worldnews EXCEPT (SELECT
headline,url,summary,updated FROM worldnews WHERE newssection='Archives'
UNION SELECT TOP 5 headline,url,summary,updated FROM worldnews WHERE
newssection='Archives' UNION SELECT TOP 5 headline,url,summary,updated FROM
worldnews WHERE newssection='Main') ORDER BY displayorder DESC


Also, if I execute the following statement, which you will notice involves
the same table and fields, on the same database:


SELECT TOP 5 headline,url,summary,updated FROM worldnews WHERE
newssection='Main' ORDER BY displayorder DESC


It executes as expected with no problem. What is the problem here? Did I
make a syntax error in the SQL statement that is giving me a problem? Is the
error because the query will return 0 records (The database does not have
many records yet since the site is not yet live)? Thanks.
 
Have you tried copying and pasting the query into an Access query
window (the SQL pane)? That will tell you whether there's a keyword
violation or not.

-mary
 
When I try it gives me the following message:

Syntax error in FROM clause.

After a little bit of experimenting, it seems like what it doesn't like is
the keyword EXCEPT. However, I cannot find a way to get the results I want
without using the EXCEPT keyword. My intended results are everything except
for the first 5 of each newssection. Because this could be any number of
records (sometimes it may be 0 records), I have to subtract the first 5 of
each newssection (using the EXCEPT keyword) from everything. Is EXCEPT not
supported in JET (because I am doing the queries through ADO.NET, I am
actually using JET, not Access)? Does anybody know of any other way to get
everything except the first 5? Thanks.
 
You're always using Jet, regardless of whether you use Access or .NET.
Jet is the actual database engine, while Access merely provides the
UI. What causes problems is that queries that are perfectly valid in
Access don't execute without it. The reason for this is that Access
contains an expression service and allows VBA functions in queries. If
you use another front-end, then the expression service and VBA aren't
available.

You can achieve the results you're looking for by using the TOP VALUES
clause. See
http://office.microsoft.com/en-us/access/HP051880331033.aspx for more
information.

--mary
 
Back
Top