0
votes

I'm getting this error when executing the following query in my code, but the query works perfectly when testing it directly in ms access.

"Error SQLSTATE[07002]: COUNT field incorrect: -3010 [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1."

select top 50 MainOrder.OrderNumber, OrderComponent.ArticleNumber, SupplierOrderMain.*, IIf(IsNull(InvoiceItems.Amount),0,InvoiceItems.Amount) AS expr1, IIF(IsNull(Customer.CustomerName),'N/A',Customer.CustomerName) AS expr2  
from Customer RIGHT JOIN (((InvoiceItems RIGHT JOIN OrderComponent ON InvoiceItems.OrderComponent = OrderComponent.ID) LEFT JOIN  MainOrder ON OrderComponent.OrderNumber = MainOrder.OrderNumber) RIGHT JOIN SupplierOrderMain ON OrderComponent.ID = SupplierOrderMain.OrderComponentID)  ON Customer.CustomerNumber = MainOrder.CustomerNumber 
where (Status = 'Status 1' or Status = 'Status 2')
order by MainOrder.OrderNumber desc, OrderComponent.ArticleNumber desc, SupplierOrderMain.Deadline desc

1

1 Answers

0
votes

Try using the SQL native "Is Null":

select top 50 
    MainOrder.OrderNumber, 
    OrderComponent.ArticleNumber, 
    SupplierOrderMain.*, 
    IIf(InvoiceItems.Amount Is Null,0,InvoiceItems.Amount) AS expr1, 
    IIF(Customer.CustomerName Is Null,'N/A',Customer.CustomerName) AS expr2  

and perhaps Status is a reserved word:

where ([Status] = 'Status 1' or [Status] = 'Status 2')