将 SQLite 与 WinRT 结合使用

发布于 2024-12-10 03:25:09 字数 230 浏览 1 评论 0原文

我正在开发一个 Metro ui 应用程序,我想使用 SQLite 来存储一些内部数据而不是 JET,以便利用一些已经编写的代码。

然而,当我尝试使用 sqlite3_open 打开数据库时,它不起作用。我收到一条错误消息,指出无法打开数据库。

我相信 SQLite 使用的某些 API 不能在 Metro 风格应用程序上使用。

有人可以帮我解决这个问题吗?至少告诉我如何确定应该移植哪些 api?

I am developing a metro ui application and I would like to use SQLite for some internal data instead of JET in order to take advantage of some already-written code.

Howerver when I try to use sqlite3_open for opening a data base, it does not work. I get an error saying a cannot open the data base.

I believe some APIs used by the SQLite cannot be used on metro style application.

Can someone help me on this? At least say me how to identify what apis should be ported?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

泼猴你往哪里跑 2024-12-17 03:25:09

这段代码应该可以工作:

auto localAppDataParh = Windows::Storage::ApplicationData::Current->LocalFolder->Path;
std::wstring path( localAppDataParh->Data() );
path += L"\\sample.db";
sqlite3* db;
int rc = sqlite3_open16( path.c_str(), &db);

我相信 SQLite 使用的某些 API 不能在 Metro 风格应用程序上使用。

可能有效(至少在预览版上),但不允许。 Windows 应用程序证书工具包 说:

   Error: This application failed the supported API check.
   API CreateFileA in kernel32.dll is not supported for this application type. 
   API CreateFileW in kernel32.dll is not supported for this application type. 
   API DeleteFileA in kernel32.dll is not supported for this application type. 
    :
    :

This code should work:

auto localAppDataParh = Windows::Storage::ApplicationData::Current->LocalFolder->Path;
std::wstring path( localAppDataParh->Data() );
path += L"\\sample.db";
sqlite3* db;
int rc = sqlite3_open16( path.c_str(), &db);

I believe some APIs used by the SQLite cannot be used on metro style application.

might work(at least on Preview Release), but not permitted. Windows App Cert Kit says:

   Error: This application failed the supported API check.
   API CreateFileA in kernel32.dll is not supported for this application type. 
   API CreateFileW in kernel32.dll is not supported for this application type. 
   API DeleteFileA in kernel32.dll is not supported for this application type. 
    :
    :
各自安好 2024-12-17 03:25:09

尝试打开本地文件夹中的数据库。这是一个有效的包装器: http://sqlwinrt.codeplex.com/

Try to open the database in the local folder. Here's a wrapper that works: http://sqlwinrt.codeplex.com/

人事已非 2024-12-17 03:25:09

刚刚发布了一个新的 WinRT SQLite3 变体,它与 Windows 应用商店指南兼容。请参阅https://github.com/doo/SQLite3-WinRT

There was just released a new WinRT SQLite3 variant, that is compatible with the Windows Store guidelines. See https://github.com/doo/SQLite3-WinRT

难得心□动 2024-12-17 03:25:09

尝试这个(仅适用于 UTF-8 数据库文件名):

int ret = Sqlite3.sqlite3_open_v2("qq.db", out db, 1, "");

有关更多信息,请参阅 sqlite.org细节。

try this one (for UTF-8 database filenames only):

int ret = Sqlite3.sqlite3_open_v2("qq.db", out db, 1, "");

See sqlite.org for more details.

看轻我的陪伴 2024-12-17 03:25:09

我还没有在 WinRT 中尝试过 sqllite,但我认为它应该可以工作。最有可能的可能性是您对尝试打开的文件没有正确的权限。检查并确保您可以使用简单的 API(如 fopen())打开文件。如果失败,那么就是权限问题。您需要将数据库放在您的应用程序拥有自然权利的目录中。例如,它不能位于用户的文档文件夹中。

I have not tried sqllite in WinRT, but I think it should work. The most likely candidate is that you do not have the correct permissions to the file you are trying to open. Check to make sure you can open the file with a simple API like fopen(). If that fails, then it is a permissions issue. You need to have your database in a directory that your app has natural rights to. It can't be in the user's documents folder for instance.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文