大家好,我的代碼大致如下:
void foo()
{
try
{
_variant_t affected = 0;
_RecordsetPtr recordset_ptr = NULL;
_ConnectionPtr connection_ptr = NULL;
recordset_ptr.CreateInstance(__uuidof(Recordset));
connection_ptr.CreateInstance(__uuidof(Connection));
// 打開鏈接
connection_ptr->open(...)
// 執行查詢
connection_ptr->BeginTrans(); // 1
recordset_ptr = connection_ptr->Excute(_bstr_t("select * from table_foo"), &affected, adCmdText);
connection_ptr->CommitTrans(); // 2
VARIANT_BOOL res = recordset_ptr->BOF; // 3
...
}
catch(_com_error &e)
{
e.ErrorMessage();
}
}
現在的情況是:
如果加上陳述句1和2,即BeginTrans()和CommitTrans(),那么執行陳述句3:VARIANT_BOOL res = recordset_ptr->BOF時
直接跳到例外里:災難性故障。
如果注釋掉陳述句1和2,即BeginTrans()和CommitTrans(),那么一切正常。
請問大家這是怎么回事?什么原理??
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/284454.html
標籤:數據庫
上一篇:opencv打開usb攝像頭問題
