SQLite数据库连接错误Xamarin形式pcl [英] SQLite database connection error Xamarin forms pcl

查看:191
本文介绍了SQLite数据库连接错误Xamarin形式pcl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Xamarin表单pcl中包含SQLite数据库时遇到问题.与iOS相关. 阅读官方网站上的指南会告诉我将其放入库/数据库",但无法进行访问.它没有连接.而不是Android的作品.

I have a problem with the inclusion of a SQLite database in Xamarin forms pcl. Related to iOS. Reading the guide on the official site tells me to put it into Library / Databases, but I can not make access. It does not connect. Instead of Android works.

我的错误:

SQLite.SQLiteException:无法打开数据库文件:/Users/my-user/Library/Developer/CoreSimulator/Devices/51FE586C-FA4D-4B13-BE27-5E3AF8D2A51E/data/Containers/Data/Application/82A0DF5E-229F- 4E4A-9A7D-25099D130AA6/Documents/Library/FimapDB.db3(CannotOpen)

SQLite.SQLiteException: Could not open database file: /Users/my-user/Library/Developer/CoreSimulator/Devices/51FE586C-FA4D-4B13-BE27-5E3AF8D2A51E/data/Containers/Data/Application/82A0DF5E-229F-4E4A-9A7D-25099D130AA6/Documents/Library/FimapDB.db3 (CannotOpen)

我的代码:

  var dbName = "FimapDB.db3";
        string personalFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.Personal);
        string libraryFolder = Path.Combine(personalFolder, "Library");
        var path = Path.Combine(libraryFolder, dbName);
        return new SQLiteConnection(path);

我设置数据库的位置:

where i have set my database:

我在哪里错了?

推荐答案

您需要将数据库复制到设备上的正确文件夹中,以便对其进行访问.

You need to copy the database into the correct folder on your device so you can access it.

可以在Xamarin论坛上找到答案:

Answer can be found on the Xamarin forums: https://forums.xamarin.com/discussion/4238/how-can-i-access-an-already-existing-sqlite-database-in-mono-for-android

这篇关于SQLite数据库连接错误Xamarin形式pcl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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