MichaelWClark 0 Junior Poster

I am running a Query that throws

"All queries combined using a UNION, INTERSECT or EXCEPT operator must have an equal number of expressions in their target lists. "

in my code, yet I can run the same query in my query browser directly on the server and it works just fine.... here is the query:

SelectCommand="
SELECT max([PURCHASE_ORDER_ID]) as [PURCHASE_ORDER_ID] from 
(SELECT 0 AS [PURCHASE_ORDER_ID] 

UNION 

SELECT max([PURCHASE_ORDER_ID]) AS [PURCHASE_ORDER_ID] FROM                 [PURCHASE_ORDER_OFFICE_EQUIPMENT] WHERE
[PURCHASE_ORDER_PROPERTY_NAME] = @ddPurchaseOrderPropertyName 

UNION

SELECT max([PURCHASE_ORDER_ID]) AS [PURCHASE_ORDER_ID] FROM [PURCHASE_ORDER_BUSINESS_EQUIPMENT] WHERE 
[PURCHASE_ORDER_PROPERTY_NAME] = @ddPurchaseOrderPropertyName 

UNION 

SELECT max([PURCHASE_ORDER_ID]) AS [PURCHASE_ORDER_ID] FROM 
[PURCHASE_ORDER_SOFTWARE_EQUIPMENT] WHERE
[PURCHASE_ORDER_PROPERTY_NAME] = @ddPurchaseOrderPropertyName)

 AS [PURCHASE_ORDER_ID]

This SQLDataSource is bound to a DropDown.... idk if that matters...@ddPurchaseOrderPropertyName binds BEFORE this control and has not caused any issues prior so I dont think its an issue there at all...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.