ADO SP calls from C++

I'm calling a stored procedure from an ATL Service and when I add a second parameter it fails (The service dies). When I comment out the second Append it works fine (if I modify the SP to only have one param). Is there something I'm missing here?

pCmd->PutRefActiveConnection(pConn);
pCmd->CommandType = adCmdStoredProc;
pCmd->CommandText = _T("usp_GetUsersForMessage");
pCmd->Parameters->Append(pCmd->CreateParameter(_T("@MsgID"),adInteger,adParamInput,4,pRS->GetCollect("ID").lVal));
pCmd->Parameters->Append(pCmd->CreateParameter(_T("@OrgID"),adInteger,adParamInput,4,pRS->GetCollect("OrgID").lVal));
pRS2 = pCmd->Execute(&v, 0, -1);
forloopAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

basantCommented:
First Check, whether you are able to create second parameter correctly

pCmd->Parameters->Append(pCmd->CreateParameter(_T("@OrgID"),adInteger,adParamInput,4,pRS->GetCollect("OrgID").lVal));

Break the sentence in three parts.

val = pRS->GetCollect("OrgID").lVal));
// Check for Error

val1 = pCmd->CreateParameter(_T("@OrgID"),adInteger,adParamInput,val);
// Check for Error
pCmd->Parameters->Append();
// Now Check for Error.

Let me know at which statement it is failing.
0
forloopAuthor Commented:
ok.. I apparently had a problem with the GetCollect, but now it fails on the Execute statement. Here's my code:

el.LogEvent(MODATL_GENERIC_ERROR, _T("Appended param two"));

pRS2 = pCmd->Execute(&v, 0, -1);

el.LogEvent(MODATL_GENERIC_ERROR, _T("Executed"));

It prints the first Event but never reaches the second one.
0
basantCommented:
Find out the actual Error No and actual Error to see what happened wrong.

Note : Use Error message from ADOs

Tell me what is the error.


Did u checked whether CreateParameter are successful or not ?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
forloopAuthor Commented:
ok.. I apparently had a problem with the GetCollect, but now it fails on the Execute statement. Here's my code:

el.LogEvent(MODATL_GENERIC_ERROR, _T("Appended param two"));

pRS2 = pCmd->Execute(&v, 0, -1);

el.LogEvent(MODATL_GENERIC_ERROR, _T("Executed"));

It prints the first Event but never reaches the second one.
0
forloopAuthor Commented:
Once again I had a problem with an outside stored proc. Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.