Why the difference between Access Query Configuration and Tableadapter Query Configuration W

I have found that I can run a query using Access query builder works fine but the same query does not work in the "TableAdapter Query Configuration Wizard". Why is this?

Example:

SELECT * from Rental_Agreement
WHERE DateSerial(year(end_date), month(end_date) , day(end_date) - 5) = Date()

This works in Acess 2003 but not in the "TableAdapter Query Configuration Wizard".

[421 byte] By [ComputerGuy] at [2007-12-23]
# 1


Are you getting an error? If so, what is it?

The primary difference is that there is functionality that is available when executing a query in Access that is not available when using the Jet database engine. A little more detail might help identify what it is.

PaulPClementIV at 2007-8-30 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 2
I just found out that DATESERIAL is not supported by ANS-SQL. Where ANSI-SQL does support DATESERIAL.
ComputerGuy at 2007-8-30 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 3

I'm going to double check this but I believe the DateSerial function is supported in one of the "sandbox" modes when using the Jet database engine.
PaulPClementIV at 2007-8-30 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 4
Thanks
Sreekumargdk at 2007-8-30 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 5


I was able to successfully use DateSerial in a SQL statement from ADO.NET.

What was the error that was being generated by your app? Are you sure it wasn't related to a bad or null date (such as a data type mismatch)?

PaulPClementIV at 2007-8-30 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 6

Hi Paul,

Thats good to hear.

I'm going to have to recreate it tonight.

RegardsDid you access an access datatable?

ComputerGuy at 2007-8-30 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 7


Yes it was an Access table. The syntax was essentially the same as yours.

You could also check the sandbox mode if the error is telling you that the function is unknown. It's stored in the Registry under the following key:

\\HKEY_LOCAL_MACHINE\Software\Microsoft\Jet\4.0\engines\SandboxMode

The value must be 2 (the default) or 3.

PaulPClementIV at 2007-8-30 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 8

I have a value of 3.

Below is doumentation for the problem.......

I enter :

SELECT * from Rental_Agreement
WHERE DateSerial(year(end_date), month(end_date) , day(end_date) - 5) = Date()

And receive error message:

Error in list of function arguments: ')' not recognized.
Unable to parse query text.

I then click the Continue button and receive the error message:

SQL Execution Error.

Executed SQL Statement: SELECT * from Rental_Agreement
WHERE DateSerial([year](end_date), [month](end_date) , [day](end_date) - 5) = Date()

Error Source: Microsoft Jet Database Engine

Error Message: Undefined Function '[Year]' in expresion

It then changed my statement to:

SELECT *
FROM Rental_Agreement
WHERE DateSerial([year](end_date), [month](end_date), [day](end_date) - 5) = DATE ()

Notice it placed square brakets [ ] around 'year' 'month' and 'day'

ComputerGuy at 2007-8-30 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 9


OK, I see what you mean. I suppose it's my tendency to avoid the GUI tools since I always seem to find limitations, so I typically either manually code the SQL or use the Access QBE to generate the SQL.

It looks to me as if the Query Builder doesn't really adequately support the same features as the Access QBE. However, as I mentioned, that query will run from ADO.NET. In addition, if you just manually enter the SQL into the CommandText property for the SelectCommand (bypass the option to automatically create the others) it should work. You just won't be able to use the Query Builder for this type of statement (although you can use Preview Data from the Data Sources window to see the data).

PaulPClementIV at 2007-8-30 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 10
Yep, I changed it in the property and right clicked and preview data and it works. Think I should run this by Microsoft?
ComputerGuy at 2007-8-30 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 11


Couldn't hurt although I wouldn't be surprised if this was "by-design". I'm fairly certain the Microsoft support folks here would see this message.

In any event, the Query Builder is obviously not parsing the SQL statement correctly for Jet OLEDB.

PaulPClementIV at 2007-8-30 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...

.NET Development

Site Classified