Unhandled exception in AddressBook.exe(KERNEL32.DLL):0xE06D7363void CAddressBookDlg::OnDelButton()
{
// TODO: Add your control notification handler code here
UpdateData(true);
POSITION pos;
int m_pos;
pos = m_ListCtrl.GetFirstSelectedItemPosition();
if(!pos)
{
::MessageBox(NULL,"请选择你要删除的记录!","删除",MB_OK | MB_ICONWARNING);
return;
}
if(IDNO==::MessageBox(NULL,"确定要删除吗?","请谨慎操作!",MB_ICONWARNING | MB_YESNO))
return;
m_pos = m_ListCtrl.GetNextSelectedItem(pos);
CString m_name,m_phone;
m_name = m_ListCtrl.GetItemText(m_pos,0);
m_phone = m_ListCtrl.GetItemText(m_pos,3);
if(ADOconnect())
{
try
{
CString strSQL;
strSQL.Format("select * from student where Name = '%s' and Phone = '%s'",m_name,m_phone);
m_recordset.CreateInstance("ADODB.Recordset");
m_recordset->Open((_variant_t)strSQL,
_variant_t((IDispatch *)ADOconnection.m_pConn,true),
adOpenStatic,
adLockOptimistic,
adCmdText
);
m_recordset = ADOconnection.m_pConn->Execute(_bstr_t(strSQL),NULL,adCmdText);
m_recordset->Delete(adAffectCurrent);
m_recordset->Update();
}
catch (_com_error &e)
{
AfxMessageBox(e.ErrorMessage());
return;
}
if(m_recordset->State)
m_recordset->Close();
}
}
删除数据库记录的代码,请赐教!
{
// TODO: Add your control notification handler code here
UpdateData(true);
POSITION pos;
int m_pos;
pos = m_ListCtrl.GetFirstSelectedItemPosition();
if(!pos)
{
::MessageBox(NULL,"请选择你要删除的记录!","删除",MB_OK | MB_ICONWARNING);
return;
}
if(IDNO==::MessageBox(NULL,"确定要删除吗?","请谨慎操作!",MB_ICONWARNING | MB_YESNO))
return;
m_pos = m_ListCtrl.GetNextSelectedItem(pos);
CString m_name,m_phone;
m_name = m_ListCtrl.GetItemText(m_pos,0);
m_phone = m_ListCtrl.GetItemText(m_pos,3);
if(ADOconnect())
{
try
{
CString strSQL;
strSQL.Format("select * from student where Name = '%s' and Phone = '%s'",m_name,m_phone);
m_recordset.CreateInstance("ADODB.Recordset");
m_recordset->Open((_variant_t)strSQL,
_variant_t((IDispatch *)ADOconnection.m_pConn,true),
adOpenStatic,
adLockOptimistic,
adCmdText
);
m_recordset = ADOconnection.m_pConn->Execute(_bstr_t(strSQL),NULL,adCmdText);
m_recordset->Delete(adAffectCurrent);
m_recordset->Update();
}
catch (_com_error &e)
{
AfxMessageBox(e.ErrorMessage());
return;
}
if(m_recordset->State)
m_recordset->Close();
}
}
删除数据库记录的代码,请赐教!
解决方案 »
- 在位图中绘图,为什么没有显示
- 如何实现接收GMAIL邮件?
- 请问如何从RegSetValueExW(HKEY hKey, LPCWSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE* lpData, DWORD cbData)的hKey
- 有关VFW中的capFileSaveDIB
- Sleep/Suspend
- 如何获取视窗宽度和高度?
- 请教:SendMessage(),PostMessage()有什么区别?
- 问一个和计算机没有一点关系的问题?
- 关于《Vc++技术内幕》
- MFC程序在自定义对话框过程函数中触发一个断点问题
- VC++ CStdioFile的ReadString函数读取长度疑问?
- vc 串口编程打开串口失败
CString strSQL;
strSQL.Format("DELETE from student where Name = '%s' and Phone = '%s'",m_name,m_phone);
ADOconnection.m_pConn->Execute(_bstr_t(strSQL),NULL,adCmdText);