I'm trying to implement a database in my Windows 8.1 Modern UI application. I made this for a Windows Phone 8.1 app successfully, but it doesn't work in a new Windows 8.1 app.
I got a SQLiteException
with message Could not open database file: MyAppBase.db (CannotOpen)
when i instanciate SQLiteConnection
public static DatabaseHelper Instance
{
get
{
if (_instance == null)
{
_instance = new DatabaseHelper();
}
return _instance;
}
}
public DatabaseHelper()
{
_connection = new SQLiteConnection(DATABASE_NAME);
_connection.CreateTable<UserEntity>();
}
I follow this steps : Added 'sqlite-net' to Nuget reference, Checked 'SQLite for Windows Runtime (Windows 8.1)' and 'Microsoft Visual C++ 2013 Runtime Package for Windows' on project references, Targetted build to x86.
How can i get this working ?
SQLite needs a path to create a DB not just a db name
try something like this
string path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, DATABASE_NAME);
_connection = new SQLite.SQLiteConnection(path)
Hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With