用MFC如何创建和删除数据库的表
若以下回答无法解决问题,邀请你更新回答
2018-05-26 · 知道合伙人互联网行家
关注
展开全部
void SearchDepartment::OnBnClickedDelete()
{
// TODO: 在此添加控件通知处理程序代码
if(m_list.GetItemCount() == 0)
{
AfxMessageBox(_T("还没有记录"));
return;
}
else if(m_list.GetSelectionMark() < 0 || m_list.GetSelectionMark() > m_list.GetItemCount())
{
AfxMessageBox(_T("请先选择记录"));
return;
} CString temp;
tempStr2 = m_list.GetItemText(m_list.GetSelectionMark(),1);
m_list.DeleteItem(m_list.GetSelectionMark()); m_db.Open(_T("peopleDSN"));
m_rs2.m_pDatabase = &m_db;
m_rs2.Open();
m_rs2.MoveFirst();
while(!m_rs2.IsEOF()){
if(m_rs2.m_dname == tempStr2){
temp = m_rs2.m_dID;
m_rs2.Close();
m_db.Close();
break;
}
else
m_rs2.MoveNext();
} m_db.Open(_T("peopleDSN"));
m_rs.m_pDatabase = &m_db;
m_rs.Open();
m_rs.MoveFirst();
while(!m_rs.IsEOF()){
if(m_rs.m_dID == temp){
m_rs.Delete();
}
else
m_rs.MoveNext();
}
m_rs.Close();
m_db.Close(); m_db.Open(_T("peopleDSN"));
m_rs2.m_pDatabase = &m_db;
m_rs2.Open();
m_rs2.MoveFirst();
while(!m_rs2.IsEOF()){
if(m_rs2.m_dname == tempStr2){
m_rs2.Delete();
m_rs2.MoveFirst();
m_rs2.Close();
m_db.Close();
return;
}
else
m_rs2.MoveNext();
}
}
{
// TODO: 在此添加控件通知处理程序代码
if(m_list.GetItemCount() == 0)
{
AfxMessageBox(_T("还没有记录"));
return;
}
else if(m_list.GetSelectionMark() < 0 || m_list.GetSelectionMark() > m_list.GetItemCount())
{
AfxMessageBox(_T("请先选择记录"));
return;
} CString temp;
tempStr2 = m_list.GetItemText(m_list.GetSelectionMark(),1);
m_list.DeleteItem(m_list.GetSelectionMark()); m_db.Open(_T("peopleDSN"));
m_rs2.m_pDatabase = &m_db;
m_rs2.Open();
m_rs2.MoveFirst();
while(!m_rs2.IsEOF()){
if(m_rs2.m_dname == tempStr2){
temp = m_rs2.m_dID;
m_rs2.Close();
m_db.Close();
break;
}
else
m_rs2.MoveNext();
} m_db.Open(_T("peopleDSN"));
m_rs.m_pDatabase = &m_db;
m_rs.Open();
m_rs.MoveFirst();
while(!m_rs.IsEOF()){
if(m_rs.m_dID == temp){
m_rs.Delete();
}
else
m_rs.MoveNext();
}
m_rs.Close();
m_db.Close(); m_db.Open(_T("peopleDSN"));
m_rs2.m_pDatabase = &m_db;
m_rs2.Open();
m_rs2.MoveFirst();
while(!m_rs2.IsEOF()){
if(m_rs2.m_dname == tempStr2){
m_rs2.Delete();
m_rs2.MoveFirst();
m_rs2.Close();
m_db.Close();
return;
}
else
m_rs2.MoveNext();
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询