相关疑难解决方法(0)

如何通过"新"运算符阻止类分配?(我想确保我的RAII类总是在堆栈上分配.)

我想确保我的RAII类总是在堆栈上分配.

如何通过"新"运算符阻止类分配?

c++ operator-overloading c++-faq

44
推荐指数
2
解决办法
8425
查看次数

_variant_t、COleVariant、CComVariant 和 VARIANT 以及使用 SAFEARRAY 变体之间的用法差异

我正在研究几个使用 ADO 访问 SQL Server 数据库的 Visual Studio 2015 C++ 项目类型。简单示例对表执行选择、读入行、更新每一行并更新表。

MFC 版本工作正常。Windows 控制台版本是我在更新记录集中的行时遇到问题的地方。update()记录集的方法抛出一个 COM 异常,错误文本为:

L"Item cannot be found in the collection corresponding to the requested name or ordinal."
Run Code Online (Sandbox Code Playgroud)

HRESULT0x800a0cc1

在这两种情况下,我都使用定义为的标准 ADO 记录集对象;

_RecordsetPtr       m_pRecordSet;   // recordset object
Run Code Online (Sandbox Code Playgroud)

在MFC版本中,更新记录集中当前行的函数是:

HRESULT CDBrecordset::UpdateRow(const COleVariant vPutFields, COleVariant vValues)
{
    m_hr = 0;
    if (IsOpened()) {
        try {
            m_hr = m_pRecordSet->Update(vPutFields, vValues);
        }
        catch (_com_error &e) {
            _bstr_t bstrSource(e.Description());
            TCHAR *description;
            description = bstrSource;
            TRACE2("  _com_error CDBrecordset::UpdateRow …
Run Code Online (Sandbox Code Playgroud)

c++ com atl ado variant

5
推荐指数
1
解决办法
2497
查看次数

标签 统计

c++ ×2

ado ×1

atl ×1

c++-faq ×1

com ×1

operator-overloading ×1

variant ×1