Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to get return string value from ADO

Status
Not open for further replies.

vicky2003

Programmer
May 27, 2003
22
CA
Hello,everyone
I met a problem when I tried to get return string by calling stored procedure in c++. Following is the code,please help me check what's wrong with it.
if(!prepareDBProcess()) return false; //this function will make connection with database,and set command properity
char strInputPara[255],strOutPara[255];
strcpy(strInputPara,"1234");
strcpy(strOutPara," ");
or memset(strOutPara,'',255);
try
{
m_pCmd->CommandText = _bstr_t(strCommandText );
VARIANT varPara1;
varPara1.bstrVal = _bstr_t(strInputPara);
varPara1.vt = VT_BSTR;
pInput = m_pCmd->CreateParameter(strInputParaName, adVarChar, adParamInput, strlen(strInputPara)*sizeof(char) ,varPara1);
m_pCmd->Parameters->Append(pInput);

VARIANT varPara2;
varPara2.bstrVal = _bstr_t(strOutPara);
varPara2.vt = VT_BSTR;
pOutput = m_pCmd->CreateParameter(strOutParaName, adVarChar, adParamOutput, strlen(strOutPara)*sizeof(char) ,varPara2);
m_pCmd->Parameters->Append(pOutput);
m_pCmd->Execute( &vtEmpty, &vtEmpty2, adCmdStoredProc );

closeCommand();
bSuccess = true;
}

the return string should be "noti"
but sometimes return string is "noti&&&&&&&&&&&&&&&&&&&&&&&&&&"
sometimes is "call ....",looks like this memory was used by others.

Thanks advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top