_variant_t Ra;
..............
try
{
g_pCn->BeginTrans();
g_pCn->Execute(updateStr1,&Ra,1);
g_pCn->Execute(updateStr2,&Ra,1);
}
catch
{
MessageBox("failed","Info");
g_pCn->Rollback();
return;
}
MessageBox("ok","Info");
g_pCn->CommitTrans();
这样不行吗?为什么在执行g_pCn->BeginTrans()的时候就会抛出异常?
但执行第二遍的时候就可以了?
大伙儿帮帮我,谢谢了!
..............
try
{
g_pCn->BeginTrans();
g_pCn->Execute(updateStr1,&Ra,1);
g_pCn->Execute(updateStr2,&Ra,1);
}
catch
{
MessageBox("failed","Info");
g_pCn->Rollback();
return;
}
MessageBox("ok","Info");
g_pCn->CommitTrans();
这样不行吗?为什么在执行g_pCn->BeginTrans()的时候就会抛出异常?
但执行第二遍的时候就可以了?
大伙儿帮帮我,谢谢了!
try
{
g_pCn->BeginTrans();
g_pCn->Execute(updateStr1,&Ra,1);
g_pCn->Execute(updateStr2,&Ra,1);
g_pCn->CommitTrans(); //应该放在这儿
}
catch(...)
{
MessageBox("failed","Info");
g_pCn->Rollback();
return;
}
MessageBox("ok","Info");
(MSDN 2001 oct.)
不过有时异常还是要捕获的