yumu_mx 2014-08-20 06:12 采纳率: 0%
浏览 2660

ado与数据库连接时成功了,但用参数化查询时却报错unkown error 0x800A0E7D

数据库用的是server 2005,但在下载时遇到了问题,,后来求助网上,完成后,程序名却叫microsoft sql server studio express,不晓得是不是数据库的问题。 希望大神指点!

以下是我的代码:
我在CADOcon定义了_connectionptr指针,所以connection这一部分应该是没问题的。
void AddUser::OnOK()
{
// TODO: Add extra validation here
try
{
UpdateData();
if(m_username.GetLength()==0&&m_pws.GetLength()==0&&m_pwsr.GetLength()==0)
{
return;
}
CADOcon adocon;
adocon.Getinado();
//添加执行命令
CommandPtr pCommand;
pCommand = NULL;
pCommand.CreateInstance(
_uuidof(Command));
_ConnectionPtr pConnection;
pCommand->ActiveConnection=pConnection;
pCommand->CommandText=("insert into 用户([用户_id],密码) values(?,?)");
pCommand->CommandTimeout=5;
_variant_t vRecordsAffected;
_ParameterPtr pParam1 =pCommand->CreateParameter(_bstr_t("用户_id"),adBSTR,adParamInput,
m_username.GetLength(),_variant_t(m_username));
_ParameterPtr pParam2 =pCommand->CreateParameter(_bstr_t("密码"),adBSTR,adParamInput,
m_username.GetLength(),_variant_t(m_pws));
pCommand->Parameters->Append(pParam1);
pCommand->Parameters->Append(pParam2);
pCommand->Execute(&vRecordsAffected,NULL,adCmdText);
if(vRecordsAffected.intVal==1)
{
AfxMessageBox("添加成功");
}
if(pConnection->State)
{
pConnection->Close();
}
}
catch(_com_error& e)
{
CString strMsg;
strMsg.Format(_T("错误描述:%s\n错误消息%s"),
(LPCTSTR)e.Description(),
(LPCTSTR)e.ErrorMessage());
AfxMessageBox(strMsg);
}

  • 写回答

1条回答 默认 最新

  • zzh1021xgz0402 2014-08-20 06:21
    关注

    爱莫能助,这个问题我得去翻翻书再来告诉你,稍等30分钟

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog