sqlserever 存储过程

wenxinfly 2016-12-19 06:19:17
CoInitialize(NULL);

HRESULT hr;
_ConnectionPtr m_pConnection;
_RecordsetPtr m_pRecordset;
_CommandPtr m_DBCommand;

m_pConnection.CreateInstance("ADODB.Connection");

m_pRecordset.CreateInstance("ADODB.Recordset");
m_DBCommand.CreateInstance(__uuidof(Command));

char szConn[512] = {0};
sprintf_s(szConn, "Provider=SQLOLEDB;Server=%s;Database=%s;uid=%s;pwd=%s","(local)", "QPAccountsDB", "sa", "421004liu");

hr = m_pConnection->Open(_bstr_t(szConn), "", "", adModeUnknown);



printf("cmd->Parameters->Count : %d\n", m_DBCommand->Parameters->Count);


_ParameterPtr Parameter = m_DBCommand->CreateParameter("@strAccounts", adWChar, adParamInput, 6, (_variant_t)"233");
m_DBCommand->Parameters->Append(Parameter);

_bstr_t vTest = m_DBCommand->Parameters->Item["@strAccounts"]->Value;

printf("cmd->Parameters->Count : %d\n", m_DBCommand->Parameters->Count);
m_DBCommand->ActiveConnection = m_pConnection;

m_DBCommand->CommandText = "AccountsLogin";
try
{
m_pRecordset->PutRefSource(m_DBCommand);
m_pRecordset->CursorLocation = adUseClient;
m_pRecordset->Open((IDispatch *)m_DBCommand, vtMissing, adOpenForwardOnly, adLockReadOnly, adOptionUnspecified);

int nValue = 0;
_variant_t vtFld = m_pRecordset->Fields->GetItem("userID")->Value;
nValue = (BYTE)vtFld.iVal;
}
catch (_com_error e)
{
char szLog[1024] = {0};
strcpy_s(szLog, (LPCSTR)_bstr_t(e.Description()));
return FALSE;
}

为什么老报
过程或函数 'AccountsLogin' 需要参数 '@strAccounts',但未提供该参数。
...全文
206 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
wenxinfly 2016-12-19
  • 打赏
  • 举报
回复
我就一个参数呀
wenxinfly 2016-12-19
  • 打赏
  • 举报
回复
ALTER PROC [dbo].[AccountsLogin] (@strAccounts nvarchar(20)) AS DECLARE @UserID INT if exists(select * from myAccount where Accounts = '234') -- 执行逻辑 BEGIN update myAccount set NickName='dgdg' where Accounts = '234' END else -- 执行逻辑 BEGIN -- 加载模块 insert into myAccount(Accounts,NickName)values('234','gdg') END SELECT @UserID=UserID from myAccount where Accounts = '234' Select @UserID AS UserID

24,854

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧