在Win IOT上连接到sqlite数据库 [英] Connect to sqlite database on win IOT

查看:103
本文介绍了在Win IOT上连接到sqlite数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到错误{SQLite.Net.SQLiteException:尝试连接到树莓派3上的sqllite数据库时,无法打开数据库文件:C:\ Data \ Users \ DefaultAccount \ Documents \ Storage.db(CannotOpen) ,使用WIN IOT是操作系统.我正在使用SQLite的SQLite.Net-PCL 3.1.1版实现.

I'm getting error {SQLite.Net.SQLiteException: Could not open database file: C:\Data\Users\DefaultAccount\Documents\Storage.db (CannotOpen) when trying to connect to sqllite database on a raspberry pi 3, with WIN IOT is the OS. I'm using the SQLite.Net-PCL ver 3.1.1 implementation of SQLite.

var documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);    var fileName2 = "Storage.db";
var path2 = Path.Combine(documentsPath, fileName2);     

try
        {
            using (var connection = new SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path2))
            {

            }
        }
        catch (Exception ex)
        {
            string m_er = ex.ToString();
        }

推荐答案

我想您使用的是UWP应用程序.在Windows IoT核心版上,您可以使用 FolderPermissions工具,以使UWP app可以访问此路径"C:\ Data \ Users \ DefaultAccount \ Documents".

I suppose you use UWP application. On Windows IoT Core you can use FolderPermissions tool to make this path "C:\Data\Users\DefaultAccount\Documents" accessible to a UWP app.

FolderPermissions C:\Data\Users\DefaultAccount\Documents -e

由于您没有收到拒绝访问"错误,因此我想您已经在Package.appxmanifest中添加了以下功能.

Since you don't receive "access denied" error so I suppose you have already added the following capability in the Package.appxmanifest.

<uap:Capability Name="documentsLibrary" />

然后您的代码将起作用. (我在具有Windows IoT核心版10.0.17763.107的Raspberry Pi 3上进行了测试)

Then your code will work. (I test on Raspberry Pi 3 with Windows IoT Core version 10.0.17763.107)

这篇关于在Win IOT上连接到sqlite数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆