首页 > 解决方案 > 如何将 wxTreeItemId 绑定为 sqlite3 数据库中的数据类型?

问题描述

我想让列wxTreeItemId作为值插入,我在sqlite中看到了这个数据类型BLOB,它接受数据,但我不确定什么sqlite3_bind_blob()作为参数,我有一个函数将列更新wxTreeItemId为,

{
    try
    {
        rc = sqlite3_open("Samples.db", &DB);

        std::string select = "UPDATE SAMPLES SET FAVORITEFOLDER = ? WHERE FILENAME = ?;";

        rc = sqlite3_prepare_v2(DB, select.c_str(), select.size(), &stmt, NULL);

---->   rc = sqlite3_bind_blob(sqlite3_stmt *, int, const void *, int n, void (*)(void *))

        rc = sqlite3_bind_text(stmt, 2, Filename.c_str(), Filename.size(), SQLITE_STATIC);

        if (sqlite3_step(stmt) == SQLITE_ROW)
        {
            wxLogDebug("Record found, updating..");
        }

        rc = sqlite3_finalize(stmt);

        if (rc != SQLITE_OK)
        {
            msgDialog = new wxMessageDialog(NULL, "Error! Cannot update record.", "Error", wxOK | wxICON_ERROR);
            msgDialog->ShowModal();
            sqlite3_free(ErrorMessage);
        }
        else
        {
            wxLogDebug("Updated record successfully.");
        }

        sqlite3_close(DB);
    }
    catch (const std::exception &exception)
    {
        wxLogDebug(exception.what());
    }
}

我想知道这些参数的期望是什么?

标签: c++sqlitewxwidgets

解决方案


wxTreeItemId内部基本上是一个指针,因此将其存储在数据库中是没有意义的。如果您需要保存对树项的引用,您需要使用它的路径,例如它在其兄弟之间的位置序列或类似的东西。


推荐阅读