recordset open异常
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总是抛出异常,不知是何原因?还请各位帮忙!
{
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总是抛出异常,不知是何原因?还请各位帮忙!
...全文
相关推荐
ASP错误总结,解决ASP错误。
**代码示例**: ```vb Dim rs As New ADODB.Recordset rs.Open "SELECT * FROM Table1", conn rs.Close rs.Open
.NET数据集到ADODB记录集的转换
**创建ADODB.Recordset对象**:使用ADODB.Recordset的Open方法,传递连接对象、SQL查询(如果是基于查询的结果集)和游标类型。
ADO操作数据库
- 打开和关闭数据库连接的方法,如Open和Close。 - 执行SQL查询或命令的方法,可能通过Command对象实现。 - 获取和操作Recordset的方法,包括选择、插入、更新和删除记录。
VC++MFC用ADO连接数据库源代码(可直接使用)
conn.Open()){ // 处理错误}```在数据库操作中,Recordset对象是关键,它代表了数据库中的记录集。
asp数据库课件(使用记录集对象)
Recordset,例如`RS.Open "SQL", Conn, CursorType, LockType, Option`。


