query runs in interface but not over ado, can't be stored via adox

J

Joe

The following query runs fine if created in the interface, but cannot be
executed over an ado connection. Error is -2147467259, Automation error,
Unspecified Error. The connection error object has not description. I've also
tried to use adox to store it and to store it manually as a test in a query
but get the same error when trying to save over adox or run over ado. As the
query is generated in code and refers to dynamically created and named
tables, I don't know how to convert it to a parameterized query (table names
can't be parameters so far as I know). To reiterate: pasting the text into a
query in the interface results in a query that can be stored and run from the
interface but not run as a stored procedure over ADO connection. What's going
on, and how can I work around this?

INSERT INTO PersonsToOrganizations ( OrgID, ID, [Position] ) SELECT
Q1.OrgID, Q1.ID, Q1.Position FROM (SELECT PM1.IDMstPerson AS OrgID,
PM.IDMstPerson AS ID, P2O1.Position AS Position FROM (([Src00001] AS S INNER
JOIN PersonMatch AS PM ON S.ID = PM.IDSrcPerson) INNER JOIN
PersonsToOrganizations_00001 AS P2O1 ON S.ID = P2O1.ID) LEFT JOIN PersonMatch
AS PM1 ON P2O1.OrgID = PM1.IDSrcPerson WHERE (((PM1.IDSrcPerson) Is Not Null)
AND ((PM1.IDSource)=1) AND ((PM1.IDMaster)=0) AND ((PM.IDSource)=1) AND
((PM.IDMaster)=0) AND ((PM.Status)>=50) AND ((S.MADEStatus)>=50) AND
((PM1.Status)>=50))) AS Q1 LEFT JOIN PersonsToOrganizations ON (Q1.Position =
PersonsToOrganizations.Position) AND (Q1.ID = PersonsToOrganizations.ID) AND
(Q1.OrgID = PersonsToOrganizations.OrgID) WHERE
(((PersonsToOrganizations.OrgID) Is Null));
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top