在MFC中 如何用函数在已有数据库添加、删除数据

来源:百度知道 编辑:UC知道 时间:2024/09/13 02:01:30
rt

//添加数据记录
void CBusinesscardView::OnMenuAddClick()
{
CAddDialog dlg;
if( dlg.DoModal()==IDOK)
{
m_pSet->AddNew();
m_pSet->m_name=dlg.m_name;
m_pSet->m_position=dlg.m_position;
m_pSet->m_telephone=dlg.m_telephone;
m_pSet->m_mobilephone=dlg.m_mobilephone;
m_pSet->m_Email=dlg.m_email;
m_pSet->m_company=dlg.m_company;
m_pSet->m_memo=dlg.m_memo;
m_pSet->Update();//保存记录
m_pSet->Requery();
m_pSet->MoveLast();
RefreshList();
}
m_pSet->MoveFirst();

}

//删除数据记录
void CBusinesscardView::OnMenuDeleteClick()
{
CDeleteDialog dlg;
if(dlg.DoModal()==IDOK)
{
CString s;
s.Format("确定要删除 “%s” 的相关信息?",dlg.m_name);
if(MessageBox(s,"删除询问",MB_OKCANCEL)==IDOK)
{
BOOL b=FALSE;