CRecordset.Open throws exception querying MS Access database "Too few parameters. Expected 1"
Posted on 2008-02-04
using a simple call:
queryStr.Format("SELECT Col1 FROM UnionQuery");
the last statement throws an exc CDBException, and the message is too few parameters, Expected 1. I cannot pinpoint the reason. The UnionQuery object is a union query, and i tried to reduce it to find the problem, but it still happens with something like this:
SELECT "a" As Name, 0 as ID, "a" as Command, "a" as ResultB64, "a" as ResultNAB64, "a" As FileName,"a" As FileVersion,"a" as LocationPath,Yes As Required,"a" As UTC, 0 As ProductID,0 As ServicePackID, Yes As Auxiliary, "a" as Exe, "a" as Switches, "a" as Cmd, "a" as prerun, "a" as postrun, 0 as RebootDetectable, 0 as Replaced, "a" as ReplacedBy, 0 as NETSEC, "a" as MS, 0 As OSID
SELECT pScript.Name, cVerify.ID, Command, ResultB64, ResultNAB64, Null, Null, Null, Null, Null,Null,Null, Null ,Null ,Null ,Null ,Null ,Null ,Null ,pScript.Replaced ,Null ,pScript.NETSEC ,pScript.MS, pScript.OSID
FROM (tableP INNER JOIN pScript ON tableP.ID = pScript.ID) INNER JOIN cVerify ON cVerify.ID = tableP.ID
WHERE tableP.ID > 0
ORDER BY Name, ID ASC
The reason for the first query in the union is to establish the column types for the rest of the query. THis is the first leg of the union, there are several more, but this seems to still reproduce the problem.