2014年3月27日09:14:22
MFC ADO 使用Oracle事务处理
代码:
try
{
CString sSQL;
pConnection->BeginTrans();
sSQL.Format(_T("insert into LWW_TEST (SN,x,y) values(5,5,5)"));
pConnection->Execute((_bstr_t)sSQL,NULL,adCmdText);
sSQL.Format(_T("update LWW_TEST set x=6 where SN=5"));
pConnection->Execute((_bstr_t)sSQL,NULL,adCmdText);
if(MessageBox(_T("是否完成修改?"), NULL, MB_ICONQUESTION | MB_YESNO)
== IDYES)
{
pConnection->CommitTrans();
}
else
{
pConnection->RollbackTrans();
}
}catch (_com_error &e)
{
CString sInfo;
sInfo.Format(_T("更新数据失败:%s"),e.ErrorMessage());
MessageBox(sInfo);
exit(-1);
}