recordset open异常

mengxiangying504 mengxiangying504 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
bool Data_Oper::add_record(const Book_Record & book_record)
{
FUNC_CALL_INFO("Data_Oper::add_record");
std::wstring sel_str = wformat(L"SELECT * FROM %s", TABLE_NAME);
try
{
record_set_ptr_->Open(_bstr_t( sel_str.c_str() ), connection_ptr_.GetInterfacePtr(),
adOpenDynamic, adLockPessimistic, adCmdText);
}
catch(_com_error e)
{
ADD_DATA_ERROR("_Recordset open unsuccessfully, error message: %s.", e.ErrorMessage());
return false;
}
try
{
record_set_ptr_->AddNew();
record_set_ptr_->PutCollect( L"姓名", _variant_t(book_record.name_.c_str()) );
record_set_ptr_->PutCollect( L"电话", _variant_t(book_record.telephone_num_.c_str()) );
record_set_ptr_->PutCollect( L"地址", _variant_t(book_record.addr_.c_str()) );
record_set_ptr_->Update();
record_set_ptr_->Close();
return true;
}
catch(_com_error e)
{
ADD_DATA_ERROR("add record failed, error message: %s.", e.ErrorMessage());
return false;
}
}

在这里的recordset 的open总是抛出异常,不知是何原因?还请各位帮忙!
...全文
评论 11
收藏 已收藏
分享
返回顶部
mengxiangying504
Access 7,731 成员 28,797 内容