I cannot create SQLiteConnection in PCL version of Sqlite.net on WP8

孤街醉人 提交于 2019-12-06 13:03:43

@Sergey-Chesalin thank you for your answers. I checked and found that it should create DB when it's not available. After my research I found why it doesn't work as it should.

For some reasons they add additional symbol to the connection string, see Line 121 in SQLiteConnection.cs and Line 196 in SQLiteConnection.cs. Maybe it works as expected in iOS/Android/WinRT versions of ISQLiteApi implementations, but it doesn't work as it should for Windows Phone.

So in order to fix it I have changed this line:

string dbFileName = Encoding.UTF8.GetString(filename, 0, filename.Length);

To this:

string dbFileName = Encoding.UTF8.GetString(filename, 0, filename.Length - 1);

in the SQLite.Net-PCL/blob/master/src/SQLite.Net.Platform.WindowsPhone8.CSharpSqlite/SQLiteApiWP8.cs line 12

Have you marked your database file file as content in project? And you can explore deployed project with ISETool or something with GUI like this to check for file existence by this path.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!