I am getting an unspecified error trying to access/run a Union query via ADO. It is sort of a complex query, but when I take the query and run it in Access (inside the database itself) it works fine, no questions asked. And the fact that I get this error:
Error Type:
(0x80004005)
Unspecified error
is really frustrating. Here is my code to create the record set:
tempStr = "SELECT '14' AS Size, sum([14]) AS tot FROM wedDetails WHERE [14m] LIKE 'AB' AND OrderID LIKE '" & nowJob & "'"
tempStr = tempStr & " UNION SELECT '20', sum([20]) AS tot FROM wedDetails WHERE [20m] LIKE 'AB' AND OrderID LIKE '" & nowJob & "'"
tempStr = tempStr & " UNION SELECT '24', sum([24]) AS tot FROM wedDetails WHERE [24m] LIKE 'AB' AND OrderID LIKE '" & nowJob & "';"
set recSet = Server.CreateObject("ADODB.Recordset"
recSet.open tempStr, strConnect, adOpenStatic ' <---- This line gives me my error.
This is basically a query to my database that would look like this:
SELECT '14' AS Size, sum([14]) AS tot FROM wedDetails WHERE [14m] LIKE 'AB' AND OrderID LIKE '12627' UNION SELECT '20', sum([20]) AS tot FROM wedDetails WHERE [20m] LIKE 'AB' AND OrderID LIKE '12627' UNION SELECT '24', sum([24]) AS tot FROM wedDetails WHERE [24m] LIKE 'AB' AND OrderID LIKE '12627';
Which should give me results like this (which I get in Access):
Size tot
14 1
20 3
24 1
Error Type:
(0x80004005)
Unspecified error
is really frustrating. Here is my code to create the record set:
tempStr = "SELECT '14' AS Size, sum([14]) AS tot FROM wedDetails WHERE [14m] LIKE 'AB' AND OrderID LIKE '" & nowJob & "'"
tempStr = tempStr & " UNION SELECT '20', sum([20]) AS tot FROM wedDetails WHERE [20m] LIKE 'AB' AND OrderID LIKE '" & nowJob & "'"
tempStr = tempStr & " UNION SELECT '24', sum([24]) AS tot FROM wedDetails WHERE [24m] LIKE 'AB' AND OrderID LIKE '" & nowJob & "';"
set recSet = Server.CreateObject("ADODB.Recordset"
recSet.open tempStr, strConnect, adOpenStatic ' <---- This line gives me my error.
This is basically a query to my database that would look like this:
SELECT '14' AS Size, sum([14]) AS tot FROM wedDetails WHERE [14m] LIKE 'AB' AND OrderID LIKE '12627' UNION SELECT '20', sum([20]) AS tot FROM wedDetails WHERE [20m] LIKE 'AB' AND OrderID LIKE '12627' UNION SELECT '24', sum([24]) AS tot FROM wedDetails WHERE [24m] LIKE 'AB' AND OrderID LIKE '12627';
Which should give me results like this (which I get in Access):
Size tot
14 1
20 3
24 1