下面给出代码,也没有抛出异常,列表框里删掉了,但在数据库里面没有删掉,如果我改过m_pConnection->Execute("delete from beiwang where users='QQ'",&RecordsAffected,adCmdText);是能删掉用户名为QQ的数据库记录的。我调试过Guser和sevent两个变量都是对的。但就是删除操作没有反应,只删除了列表框里的数据。
void CDelbeiwang::Ondelbeiwang()
{
// _variant_t vuser,vevents;
HWND hWnd = ::GetDlgItem(m_hWnd, IDC_LIST1);
CListCtrl * m_List=((CListCtrl * )GetDlgItem(IDC_LIST1));
int nitem=m_List->GetSelectionMark();
CString sevent=GetItemText(hWnd,nitem,1);
try
{
m_pConnection->Execute("delete from beiwang where users='+Guser+' and events='+sevent+'",&RecordsAffected,adCmdText);
}
catch(_com_error e)
{
AfxMessageBox(e.ErrorMessage(),MB_OK,0);
}
m_list.DeleteItem(m_List->GetSelectionMark());
UpdateData(FALSE);
// TODO: Add your control notification handler code here
}
void CDelbeiwang::Ondelbeiwang()
{
// _variant_t vuser,vevents;
HWND hWnd = ::GetDlgItem(m_hWnd, IDC_LIST1);
CListCtrl * m_List=((CListCtrl * )GetDlgItem(IDC_LIST1));
int nitem=m_List->GetSelectionMark();
CString sevent=GetItemText(hWnd,nitem,1);
try
{
m_pConnection->Execute("delete from beiwang where users='+Guser+' and events='+sevent+'",&RecordsAffected,adCmdText);
}
catch(_com_error e)
{
AfxMessageBox(e.ErrorMessage(),MB_OK,0);
}
m_list.DeleteItem(m_List->GetSelectionMark());
UpdateData(FALSE);
// TODO: Add your control notification handler code here
}
解决方案 »
- 疑惑的问题
- 怎样返回一个结点列表?
- 在IIS6中,使用通配符ISAPI扩展为什么得不到时用户提交的数据(即entity),有人做过吗?
- 唉!原来五颗星变成只有一颗星了! 伤心之余只好放分!
- 无法连接邮件服务器
- 如果让监控程序不能关闭也不能卸载?
- 一个socket的入门问题~~~
- 如何获取最小化按钮消息?PreTranslateMessage(MSG* pMsg)如何处理?
- 怎样把用autocad14画的图给加栽到一个基于单文档程序中!!
- 在 Atl Control 的对话框资源上 添加了 Flash ActiveX,如何在新添加的接口的方法中获取到Flash Acitivex的接口?
- VC中ADO打开.csv数据文件并读取其中的字段?
- *.db文件如何访问
m_pCommand->ActiveConnection = theApp.m_pConnection; // 将库连接赋于它
m_pCommand->CommandText = _bstr_t((LPCTSTR)m_strCommand); // SQL语句
try
{
// 执行SQL语句,返回记录集,此记录不能做插入操作
// 故为了不和m_pRecordset相冲突, 放入新定义的m_pRecordset1
m_pRecordset1 = m_pCommand->Execute( NULL, NULL, adCmdText);
}
catch(_com_error& e)
{
dump_com_error(e);
}