I want to use a parameter query from a C++ based program with ADO. I suspect that I am not using the correct information for the ADO Command. Can anyone suggest what may be required.

The code gives an error message:-
Item canot be found in the collection corresponding to the requested name or ordinal.

The query in Access starts with:-
PARAMETERS lBereich Long, dteFrom DateTime, dteTo DateTime;
SELECT

and the code is:-
_CommandPtr pCmd("ADODB.Command");
pCmd->ActiveConnection = pCn;
pCmd->CommandText = _T("Controlling_IndKost_Eigenes");
pCmd->CommandType = adCmdStoredProc;
pCmd->Parameters->Refresh();

pCmd->Parameters->Item[_bstr_t(L"lBereich")]->Value = _variant_t((long) m_iBereich);
pCmd->Parameters->Item[_bstr_t(L"dteFrom")]->Value = _variant_t((double) dteFrom.m_dt);
pCmd->Parameters->Item[_bstr_t(L"dteTo")]->Value = _variant_t((double) dteTo.m_dt);
pRS = pCmd->Execute( NULL, NULL, adCmdStoredProc );



If I use the following code then it works perfectly:-
_CommandPtr pCmd("ADODB.Command");
pCmd->ActiveConnection = pCn;
pCmd->CommandText = _T("Controlling_IndKost_Eigenes");
pCmd->CommandType = adCmdStoredProc;

pCmd->Parameters->Append(pCmd->CreateParameter("lBereich", adBigInt, adParamInput, sizeof(long)));
pCmd->Parameters->Append(pCmd->CreateParameter("dteFrom", adDate, adParamInput, sizeof(double)));
pCmd->Parameters->Append(pCmd->CreateParameter("dteTo", adDate, adParamInput, sizeof(double)));

pCmd->Parameters->Item[_bstr_t(L"lBereich")]->Value = _variant_t((long) m_iBereich);
pCmd->Parameters->Item[_bstr_t(L"dteFrom")]->Value = _variant_t((double) dteFrom.m_dt);
pCmd->Parameters->Item[_bstr_t(L"dteTo")]->Value = _variant_t((double) dteTo.m_dt);
pRS = pCmd->Execute( NULL, NULL, adCmdStoredProc );


Win 2000 SP1.
Access 2000 (German, no SP).
Visual Studio 6 (SP 5).
MSDAC_TYP installed (2.6)