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.
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.