SQL2005插入和修改记录时发生RUNtime的错误,请帮忙分析下原因,代码如下
void CExec4Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
UpdateData();
if(m_sname == "" || m_sno == "")
{
AfxMessageBox("学号和姓名信息不能为空!");
return;
}
try
{
m_pRecordset->AddNew();
m_pRecordset->PutCollect("sno", _variant_t(m_sno));
m_pRecordset->PutCollect("sname", _variant_t(m_sname));
m_pRecordset->PutCollect("age", _variant_t(m_age));
m_pRecordset->PutCollect("dept", _variant_t(m_dept));
m_pRecordset->PutCollect("comment", _variant_t(m_comment));
m_pRecordset->Update();
UpdateData(false);
AfxMessageBox("插入成功!");
int nCurSel = m_list.GetCurSel();
List();
//m_list.SetCurSel(nCurSel);
OnSelchangeList1();
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
}、
MFC 函数添加记录到数据库时候执行 至红色的代码发生了runtime错误,!!数据库是联通了,而且可以在列表框里显示和查找数据库的内容,就是插入和修改记录这两个功能一执行就会发生runtime错误。求大神帮忙分析下是什么原因,本人菜鸟刚学的。
[解决办法]
这里有解决方案:
http://topic.csdn.net/t/20060709/10/4868751.html
[解决办法]
m_pRecordset->PutCollect("sno",_variant_t((long)m_sno))