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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unspecified error on Union Query using ADO.

Status
Not open for further replies.

qwert231

Programmer
Sep 4, 2001
756
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top