Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access UNION query in ASP

Status
Not open for further replies.

stevetektip

Programmer
Oct 17, 2002
6
US
Hi all,
I've got a Union query that works fine in Access 2000, but when I run the query in an ASP file (MDAC 2.7 using ODBC connection to mdb file) I get the error:
---------------------------------------
Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
---------------------------------------
I didn't find anyting in the MS knowledge base about this type of query either.

Here's the query...
---------------------------------------
select feature_id, 1 as phase from projects where (datediff("m",#9/10/2003#,demo_start) >6)
union
select feature_id, 2 as phase from projects where (datediff(&quot;m&quot;,#9/10/2003#,demo_start) <=6) and (datediff(&quot;m&quot;,#9/10/2003#,demo_start) >0)
---------------------------------------
Rather simple, works fine in Access 2000, but crashes & burns when run with ASP.

Any suggestions would be greatly appreciated.
Thanks!
 
Im not familiar with ASP but if your query was run
in access 2000 as anything other than a stored query,
you would most probably run into the same problem unless the
sql was built taking into account the use of &quot; around the &quot;m&quot; of the date functions you are using.They would cause that error in access
 
The solution turns out to be the use of the double quote around the m for the datediff function call. Using a single quote ' instead of the double quote &quot; fixes the problem
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top