Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access ASP
| Search | Today's Posts | Mark Forums Read
Access ASP Using ASP with Microsoft Access databases. For Access questions not specific to ASP, please use the Access forum. For more ASP forums, please see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access ASP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old November 15th, 2006, 10:27 AM
Registered User
 
Join Date: Nov 2006
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem running SQL query on Access

Hi I am trying to convert my website from SQL to MS Access so that I can keep a functional backup in Access.

On this page, I am getting the following error:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Wrong number of arguments used with function in query expression 'isnull(tradeprice,UnitPrice)'.

This is the coresponding area of code producing the error. (All code works perfectly in SQL, but gives this error in Access)

<%
Dim rsSpecial
Dim mstrSql
Dim rsSpecial_numRows
mstrSql = "SELECT ProductID, SubCatagoryID, ProductName, ProductPict, SpecialPrice,"
     if isTradeAccount then
        mstrSql = mstrSql & "isnull(tradeprice,UnitPrice)"
     else
        mstrSql = mstrSql & "UnitPrice"
     end if

  mstrSql = mstrSql & " as UnitPrice, 0 as ProductDetailID FROM Products WHERE Special = 'Yes' and ProductID not in (select ProductID from ProductDetails) union " & _
   "SELECT po.ProductID, po.SubCatagoryID, po.ProductName,pr.Pict as ProductPict, " & _
     "isnull(pr.SpecialPrice,po.SpecialPrice) as SpecialPrice,"
     if isTradeAccount then
        mstrSql = mstrSql & "isnull(pr.tradeprice,pr.UnitPrice)"
     else
        mstrSql = mstrSql & "pr.UnitPrice"
     end if
     mstrSql = mstrSql & " as UnitPrice,pr.ProductDetailID FROM Products po inner join productDetails pr on po.ProductID=pr.ProductID WHERE pr.onSpecial = 'Yes' order by ProductDetailID, SubCatagoryID DESC"

Set rsSpecial = Server.CreateObject("ADODB.Recordset")
rsSpecial.ActiveConnection = MM_connTS_STRING
rsSpecial.Source = mstrSql
rsSpecial.CursorType = 0
rsSpecial.CursorLocation = 2
rsSpecial.LockType = 1
rsSpecial.Open()

rsSpecial_numRows = 0
%>

What should I change to get this to work?
Thanks for you help in advance,
Joe

  #2 (permalink)  
Old November 26th, 2006, 06:09 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Melbourne, Vic, Australia.
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The problem is that ISNULL functions differently in Access.
In Access, IsNull returns True or False for ONE parameter.
I'd suggest using IIF (check Access Help) with something like:
Code:
mstrSql = "SELECT ProductID, SubCatagoryID, ProductName, ProductPict, SpecialPrice,"
     if isTradeAccount then
        mstrSql = mstrSql & "iif(tradeprice is null, UnitPrice, tradeprice)"
     else
        mstrSql = mstrSql & "UnitPrice"
     end if

I am a loud man with a very large hat. This means I am in charge


Similar Threads
Thread Thread Starter Forum Replies Last Post
Running an Access Query from ASP arholly Access ASP 0 January 25th, 2008 03:31 PM
SQL query problem in Access - Urgent Kaustav Access 2 September 30th, 2005 11:39 PM
SQL query question in Access dlamarche Access 3 April 3rd, 2005 10:42 PM
problem running ms access application method Access 1 March 23rd, 2005 09:16 AM
Running an SQL query in VBA... Augusta Access VBA 3 December 1st, 2004 05:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.