Accessing ADO output parameters from SQL Server to VC++.net
From: nadimpal99 (nadimpal99_at_discussions.microsoft.com)
Date: 08/19/04
- Next message: Gurkan: "SqlDataAdapter & Stored Procedure"
- Previous message: Mary Chipman: "Re: ADODB Fails with Run-time error '-2147024769 (8007007f)"
- Next in thread: John Wadie: "RE: Accessing ADO output parameters from SQL Server to VC++.net"
- Reply: John Wadie: "RE: Accessing ADO output parameters from SQL Server to VC++.net"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 19 Aug 2004 07:19:08 -0700
I have a stored procedure in SQL Server database with one input and one
output parameters. I am able to run the stored procedure from VC++ through
ADO, but cannot access the output value. I am new to ADO through VC++.
Please find my VC++ code below. Any help/suggestions appreciated.
/****************************************************/
_CommandPtr myCmd;
_ParameterPtr myPrm;
int myTag;
VARIANT vtTag;
VARIANT vtRtn;
_variant_t field;
_bstr_t sSize;
int rtn;
HRESULT hr;
rtn = ds_sql_connect_host();
hr = myCmd.CreateInstance(__uuidof(Command));
if(FAILED(hr))
{
printf("Can't Create an instance of Command!\n");
return 0;
}
myCmd->CommandText = "mhc_new_spool";
myCmd->CommandType = adCmdStoredProc;
myTag = 1076806;
vtTag.vt = VT_INT;
vtTag.intVal = myTag;
myPrm = myCmd->CreateParameter("tag", adInteger, adParamInput,
sizeof(int), vtTag);
myCmd->Parameters->Append(myPrm);
myPrm->Value = vtTag;
vtRtn.vt = VT_INT;
myPrm = myCmd->CreateParameter("rtn", adInteger, adParamOutput,
sizeof(int), vtRtn);
myCmd->Parameters->Append(myPrm);
myPrm->Value = vtRtn;
myCmd->ActiveConnection = DBconnP;
myCmd->Execute(NULL, NULL, adCmdStoredProc);
rtn = (int)(vtRtn.intVal);
/****************************************************/
-- nadimpal99
- Next message: Gurkan: "SqlDataAdapter & Stored Procedure"
- Previous message: Mary Chipman: "Re: ADODB Fails with Run-time error '-2147024769 (8007007f)"
- Next in thread: John Wadie: "RE: Accessing ADO output parameters from SQL Server to VC++.net"
- Reply: John Wadie: "RE: Accessing ADO output parameters from SQL Server to VC++.net"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|