• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 329
  • Last Modified:

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);
0
forloop
Asked:
forloop
  • 3
  • 2
1 Solution
 
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
 
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

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now