今天在做毕业设计的时候遇到一个很奇怪的问题,我以前通过传递三个参数的存储过程调用都还是很成功的,为什么今天就不行了呢?代码如下:
HRESULT hr;
if (m_pCmd == NULL)
{
hr = m_pCmd.CreateInstance(__uuidof(Command));
if(FAILED(hr))
{
AfxMessageBox("创建_CommandPtr对象失败");
return FALSE;
}
}
_ParameterPtr param1, param2, param3;
param1.CreateInstance(__uuidof(Parameter));
param2.CreateInstance(__uuidof(Parameter));
param3.CreateInstance(__uuidof(Parameter));
try
{
param1 = m_pCmd->CreateParameter("user_id",adInteger, adParamInput,
4, _variant_t((long)userId));
m_pCmd->Parameters->Append(param1);
param2 = m_pCmd->CreateParameter("bycle_id",adInteger, adParamInput,
4, _variant_t((long)bycleId));
m_pCmd->Parameters->Append(param2);
param3 = m_pCmd->CreateParameter("error_code",adInteger, adParamOutput,
4, _variant_t((long)iErrorCode));
m_pCmd->Parameters->Append(param3);
m_pCmd->ActiveConnection = m_pConn;
m_pCmd->CommandText = "rent_bycle_main";
m_pCmd->CommandType = adCmdStoredProc;
m_pCmd->Execute(NULL, NULL, adCmdStoredProc);
iErrorCode = (long)m_pCmd->Parameters->GetItem("error_code")->GetValue();
}
catch (_com_error& e)
{
dump_com_error(e);
return FALSE;
}
存储过程如下:
HRESULT hr;
if (m_pCmd == NULL)
{
hr = m_pCmd.CreateInstance(__uuidof(Command));
if(FAILED(hr))
{
AfxMessageBox("创建_CommandPtr对象失败");
return FALSE;
}
}
_ParameterPtr param1, param2, param3;
param1.CreateInstance(__uuidof(Parameter));
param2.CreateInstance(__uuidof(Parameter));
param3.CreateInstance(__uuidof(Parameter));
try
{
param1 = m_pCmd->CreateParameter("user_id",adInteger, adParamInput,
4, _variant_t((long)userId));
m_pCmd->Parameters->Append(param1);
param2 = m_pCmd->CreateParameter("bycle_id",adInteger, adParamInput,
4, _variant_t((long)bycleId));
m_pCmd->Parameters->Append(param2);
param3 = m_pCmd->CreateParameter("error_code",adInteger, adParamOutput,
4, _variant_t((long)iErrorCode));
m_pCmd->Parameters->Append(param3);
m_pCmd->ActiveConnection = m_pConn;
m_pCmd->CommandText = "rent_bycle_main";
m_pCmd->CommandType = adCmdStoredProc;
m_pCmd->Execute(NULL, NULL, adCmdStoredProc);
iErrorCode = (long)m_pCmd->Parameters->GetItem("error_code")->GetValue();
}
catch (_com_error& e)
{
dump_com_error(e);
return FALSE;
}
SQL Server 2000的存储过程
alter procedure rent_bycle_main (@user_id int, @bycle_id int, @if_can_borrow int out)
as
begin
declare @borrow_flag int, @user_title varchar(8), @avail_time int, @date_hour int;
select @if_can_borrow = 0;
select @borrow_flag = user_if_borrow, @user_title = user_title
from userInfo where user_id = @user_id;
if (@borrow_flag = 1)
。。。。。
SQL Server 2000的存储过程
alter procedure rent_bycle_main (@user_id int, @bycle_id int, @if_can_borrow int out)
as
begin
declare @borrow_flag int, @user_title varchar(8), @avail_time int, @date_hour int;
select @if_can_borrow = 0;
select @borrow_flag = user_if_borrow, @user_title = user_title
from userInfo where user_id = @user_id;
if (@borrow_flag = 1)
。。。。。