dlg.InsertDate(m_InName, m_InDate, m_InSWork, m_InOWork, m_InTime1, m_InTime, m_InWork,m_InBeiZhu);调用CAdoRWAccessDlg中的函数CAdoRWAccessDlg::InsertDate(CString InName, COleDateTime InDate, CString InSWork, CString InOWork, CString InTime1, CString InTime, CString InWork,CString InBeiZhu)来添加新的记录,为什么总是不成功?请高手指点下~~~
6 个解决方案
#1
问题补充:在CAdoRWAccessDlg::InsertDate(CString InName, COleDateTime InDate, CString InSWork, CString InOWork, CString InTime1, CString InTime, CString InWork,CString InBeiZhu)函数中不添加代码没出错,但加入以下代码就出错:
UpdateData();
try
{
// 写入各字段值
m_pRecordset->AddNew();
m_pRecordset->PutCollect("姓名", _variant_t(m_Name));
m_pRecordset->PutCollect("考勤日期", _variant_t(m_Date));
m_pRecordset->PutCollect("上班时间", _variant_t(m_SWork));
m_pRecordset->PutCollect("下班时间", _variant_t(m_OWork));
m_pRecordset->PutCollect("出勤时间", _variant_t(m_Timer));
m_pRecordset->PutCollect("时间段", _variant_t(m_Timer2));
m_pRecordset->PutCollect("工作内容", _variant_t(m_Work));
m_pRecordset->PutCollect("备注", _variant_t(m_BeiZhu));
MessageBox("插入成功!","提示");
// 更新显示其库内容
int nCurSel = m_AccessList.GetCurSel();
OnReadAccess();
m_AccessList.SetCurSel(nCurSel);
// 移动记录指针到新的位置
OnSelchangeListaccess();
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
UpdateData();
try
{
// 写入各字段值
m_pRecordset->AddNew();
m_pRecordset->PutCollect("姓名", _variant_t(m_Name));
m_pRecordset->PutCollect("考勤日期", _variant_t(m_Date));
m_pRecordset->PutCollect("上班时间", _variant_t(m_SWork));
m_pRecordset->PutCollect("下班时间", _variant_t(m_OWork));
m_pRecordset->PutCollect("出勤时间", _variant_t(m_Timer));
m_pRecordset->PutCollect("时间段", _variant_t(m_Timer2));
m_pRecordset->PutCollect("工作内容", _variant_t(m_Work));
m_pRecordset->PutCollect("备注", _variant_t(m_BeiZhu));
MessageBox("插入成功!","提示");
// 更新显示其库内容
int nCurSel = m_AccessList.GetCurSel();
OnReadAccess();
m_AccessList.SetCurSel(nCurSel);
// 移动记录指针到新的位置
OnSelchangeListaccess();
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
#2
插入代码以后再UpdateData试试行吗
#3
不行的,只有UpdateData()或UpdateData(FALSE)一代码,运行时都会出错?
#4
m_pRecordset->PutCollect("姓名", _variant_t(m_Name));
m_pRecordset->PutCollect("考勤日期", _variant_t(m_Date));
m_pRecordset->PutCollect("上班时间", _variant_t(m_SWork));
m_pRecordset->PutCollect("下班时间", _variant_t(m_OWork));
m_pRecordset->PutCollect("出勤时间", _variant_t(m_Timer));
m_pRecordset->PutCollect("时间段", _variant_t(m_Timer2));
m_pRecordset->PutCollect("工作内容", _variant_t(m_Work));
m_pRecordset->PutCollect("备注", _variant_t(m_BeiZhu));
這些有問題吧,你用Messbox("dd")語句來,確定一下出錯的位置。
m_pRecordset->PutCollect("考勤日期", _variant_t(m_Date));
m_pRecordset->PutCollect("上班时间", _variant_t(m_SWork));
m_pRecordset->PutCollect("下班时间", _variant_t(m_OWork));
m_pRecordset->PutCollect("出勤时间", _variant_t(m_Timer));
m_pRecordset->PutCollect("时间段", _variant_t(m_Timer2));
m_pRecordset->PutCollect("工作内容", _variant_t(m_Work));
m_pRecordset->PutCollect("备注", _variant_t(m_BeiZhu));
這些有問題吧,你用Messbox("dd")語句來,確定一下出錯的位置。
#5
这个应该不会有问题吧?
#6
m_pRecordset->Update();
MessageBox("插入成功!","提示");
m_pRecordset->Update();一定要调用,不然,修改、删除都不成功!
MessageBox("插入成功!","提示");
m_pRecordset->Update();一定要调用,不然,修改、删除都不成功!
#1
问题补充:在CAdoRWAccessDlg::InsertDate(CString InName, COleDateTime InDate, CString InSWork, CString InOWork, CString InTime1, CString InTime, CString InWork,CString InBeiZhu)函数中不添加代码没出错,但加入以下代码就出错:
UpdateData();
try
{
// 写入各字段值
m_pRecordset->AddNew();
m_pRecordset->PutCollect("姓名", _variant_t(m_Name));
m_pRecordset->PutCollect("考勤日期", _variant_t(m_Date));
m_pRecordset->PutCollect("上班时间", _variant_t(m_SWork));
m_pRecordset->PutCollect("下班时间", _variant_t(m_OWork));
m_pRecordset->PutCollect("出勤时间", _variant_t(m_Timer));
m_pRecordset->PutCollect("时间段", _variant_t(m_Timer2));
m_pRecordset->PutCollect("工作内容", _variant_t(m_Work));
m_pRecordset->PutCollect("备注", _variant_t(m_BeiZhu));
MessageBox("插入成功!","提示");
// 更新显示其库内容
int nCurSel = m_AccessList.GetCurSel();
OnReadAccess();
m_AccessList.SetCurSel(nCurSel);
// 移动记录指针到新的位置
OnSelchangeListaccess();
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
UpdateData();
try
{
// 写入各字段值
m_pRecordset->AddNew();
m_pRecordset->PutCollect("姓名", _variant_t(m_Name));
m_pRecordset->PutCollect("考勤日期", _variant_t(m_Date));
m_pRecordset->PutCollect("上班时间", _variant_t(m_SWork));
m_pRecordset->PutCollect("下班时间", _variant_t(m_OWork));
m_pRecordset->PutCollect("出勤时间", _variant_t(m_Timer));
m_pRecordset->PutCollect("时间段", _variant_t(m_Timer2));
m_pRecordset->PutCollect("工作内容", _variant_t(m_Work));
m_pRecordset->PutCollect("备注", _variant_t(m_BeiZhu));
MessageBox("插入成功!","提示");
// 更新显示其库内容
int nCurSel = m_AccessList.GetCurSel();
OnReadAccess();
m_AccessList.SetCurSel(nCurSel);
// 移动记录指针到新的位置
OnSelchangeListaccess();
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
#2
插入代码以后再UpdateData试试行吗
#3
不行的,只有UpdateData()或UpdateData(FALSE)一代码,运行时都会出错?
#4
m_pRecordset->PutCollect("姓名", _variant_t(m_Name));
m_pRecordset->PutCollect("考勤日期", _variant_t(m_Date));
m_pRecordset->PutCollect("上班时间", _variant_t(m_SWork));
m_pRecordset->PutCollect("下班时间", _variant_t(m_OWork));
m_pRecordset->PutCollect("出勤时间", _variant_t(m_Timer));
m_pRecordset->PutCollect("时间段", _variant_t(m_Timer2));
m_pRecordset->PutCollect("工作内容", _variant_t(m_Work));
m_pRecordset->PutCollect("备注", _variant_t(m_BeiZhu));
這些有問題吧,你用Messbox("dd")語句來,確定一下出錯的位置。
m_pRecordset->PutCollect("考勤日期", _variant_t(m_Date));
m_pRecordset->PutCollect("上班时间", _variant_t(m_SWork));
m_pRecordset->PutCollect("下班时间", _variant_t(m_OWork));
m_pRecordset->PutCollect("出勤时间", _variant_t(m_Timer));
m_pRecordset->PutCollect("时间段", _variant_t(m_Timer2));
m_pRecordset->PutCollect("工作内容", _variant_t(m_Work));
m_pRecordset->PutCollect("备注", _variant_t(m_BeiZhu));
這些有問題吧,你用Messbox("dd")語句來,確定一下出錯的位置。
#5
这个应该不会有问题吧?
#6
m_pRecordset->Update();
MessageBox("插入成功!","提示");
m_pRecordset->Update();一定要调用,不然,修改、删除都不成功!
MessageBox("插入成功!","提示");
m_pRecordset->Update();一定要调用,不然,修改、删除都不成功!