alv*_*oun 5 windows-store-apps sqlite-net
我正在尝试在Windows 8.1 Modern UI应用程序中实现数据库.我成功地为Windows Phone 8.1应用程序做了这个,但它在新的Windows 8.1应用程序中不起作用.
当我实现时,我收到了一条SQLiteException消息Could not open database file: MyAppBase.db (CannotOpen)SQLiteConnection
public static DatabaseHelper Instance
{
get
{
if (_instance == null)
{
_instance = new DatabaseHelper();
}
return _instance;
}
}
public DatabaseHelper()
{
_connection = new SQLiteConnection(DATABASE_NAME);
_connection.CreateTable<UserEntity>();
}
Run Code Online (Sandbox Code Playgroud)
我按照以下步骤:在项目引用,Targetted build to x86上添加'sqlite-net'到Nuget引用,Checked'SQLite for Windows Runtime(Windows 8.1)'和'Microsoft Visual C++ 2013 Runtime Package for Windows'.
我怎样才能使这个工作?
SQLite需要一个创建数据库的路径而不仅仅是数据库名称
尝试这样的事情
string path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, DATABASE_NAME);
_connection = new SQLite.SQLiteConnection(path)
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助
| 归档时间: |
|
| 查看次数: |
2307 次 |
| 最近记录: |