String as output from SP in C++



I can't seem to properly form a CreateParamter statement for retrieving a
string from a stored procedure. The SP looks a bit like this:
---------------------------------------------
CREATE PROCEDURE dbo.qry_MyQry
@l_spec_cd as int,
@s_addr_list_txt nvarchar(2560) OUTPUT

AS
SET NOCOUNT ON

DECLARE @my_email_txt nvarchar(1280)

SELECT @my_email_txt=EmailAddrTxt
FROM tblPhysician
WHERE PhysicianCd = @l_spec_cd

..
..
..


SET @s_addr_list_txt = @s_addr_list_txt + @my_email_txt

GO
----------------------------------------------

Then in my C++ code I have the following:
----------------------------------------------
_CommandPtr cmd("ADODB.Command");
_ParameterPtr param;

email_addr_list = L"";

cmd->ActiveConnection = _epi_conn;
cmd->CommandText = "qry_MsgEmailPhysEmail";
cmd->CommandType = adCmdStoredProc;

//
// get admitting and/or ordering physician email addrs
//
_variant_t var_phy_email;
CString s_phy_email;

//
// setup stored procedure call
//
param = cmd->CreateParameter (_bstr_t("@l_spec_cd"), adInteger,
adParamInput, 4);
cmd->Parameters->Append(param);
param->Value = spec_cd;

var_phy_email.vt = VT_BSTR;
param = cmd->CreateParameter (_bstr_t("@s_addr_list_txt"), adVarChar,
adParamOutput, 2560, var_phy_email);
cmd->Parameters->Append(param);

cmd->Execute(NULL, NULL, adCmdStoredProc);
---------------------------------------------------------------------

I get an exception while doing the second create parameter for the return
string. Not sure if its a a poorly formatted call to CreateParameter,
illegal variable in that call, or some other violation.

Help?!

.



Relevant Pages

  • RE: SQL stored procedure executing twice
    ... from one parent record to another. ... Dim stDocName As String ... My pass-thru query syntax going to stored procedure ...
    (microsoft.public.access.modulesdaovba)
  • RE: MS Query "Connections"
    ... handle that with my connection string. ... for using the stored procedure route is that it is faster. ... If you truly want to pass in the query string, ...
    (microsoft.public.excel.programming)
  • Re: XML binding advice
    ... Performance - By writing the SQL statement as a stored procedure, ... execution plan will take into account any indexes you have on the tables ... each piece you add to the string. ...
    (microsoft.public.dotnet.xml)
  • Re: TableAdapter specifing IN in the where clause for list of id
    ... And till now, there products which are huge products, they are using AD-HOC ... Since IN cannot accept a delimited string but ... Muhammad replied that I could use a stored procedure to accomplish this ... specify. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Creating A Custom Collection
    ... You'll have to get away from using multidimensional arrays. ... > string StoredProcedureName, string UserName, string TransactionType ... > stored procedure so it can walk this object to create a SqlCommand ... > send the name of the proc and the parameters object to the data layer ...
    (microsoft.public.dotnet.framework)