4,011
社区成员
发帖
与我相关
我的任务
分享
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();
}
}