我在用ADO时出现了以下错误:
在
代码为:
void CManageDlg::OnButton2()
{
// TODO: Add your control notification handler code here
m_cmd.CreateInstance("ADODB.Command");
if(!UpdateData())
return;
int nitem=m_ctrllist.GetNextItem(-1,LVNI_SELECTED);
if(nitem==-1)
{
MessageBox("请选择!");
return;
}
if(m_strname.IsEmpty())
{
MessageBox("客户名字不能为空");
return;
}
try
{
int id=atoi(m_ctrllist.GetItemText(nitem,0));
_variant_t vnull;
vnull.vt=VT_ERROR;
vnull.scode=DISP_E_PARAMNOTFOUND;
CString sql;
sql.Format("update CUSTOMER set NAME='%s',ADDR='%s',COMPANY='%s',PHONE='%s' where CUST_ID=%d",m_strname,m_straddr,m_strcompany,m_strphone,id);
m_cmd->ActiveConnection=m_conn;
m_cmd->CommandText=_bstr_t(sql);
m_cmd->Execute(&vnull,&vnull,adCmdText);
m_ctrllist.SetItemText(nitem,1,m_strname);
m_ctrllist.SetItemText(nitem,2,m_straddr);
m_ctrllist.SetItemText(nitem,3,m_strcompany);
m_ctrllist.SetItemText(nitem,4,m_strphone);
UpdateData(false);
// m_cmd.Release();
}
catch(_com_error e)
{
MessageBox(e.ErrorMessage());
}
}
运行时出现IDispatch error #3902的错误提示,
请问怎么解决啊,急!!!!!!!!!1