Windows phone 8 Sqlite设置

时间:2013-05-21 20:45:26

标签: database sqlite visual-studio-2012 windows-phone-8

我开始设置windows phone 8 sqlite,一切都很棒。我安装了SQL for Windows手机扩展。然后我继续添加解决方案(Sqlite.vcxproj)。之后我添加了文件Sqlite.cs和SqliteAsync.cs。然后我引用了Windows手机的sqlite添加引用,一切似乎都很好。最后,我将USE_WP8_NATIVE_SQLITE添加到构建属性中。 (我跟着 - > THIS guide

首先我遇到SQLite3缺少命名空间的问题,但后来我在手动添加Community.CsharpSqlite.SQLiteClient.WP.dll,Community.CsharpSqlite.WinPhone.dll,System.Data.Ersatz.WinPhone.dll后修复了它。

问题是,当我插入此代码时:

private async void CreateDatabase()
{
SQLiteAsyncConnection conn = new SQLiteAsyncConnection(Path.Combine(ApplicationData.Current.LocalFolder.Path, "people.db"), true);
await conn.CreateTableAsync<Person>();
}

我一直在获取名称空间名称SQLiteAsyncConnection无法找到(你是否缺少指令或程序集引用?)错误。

是否发生这种情况,因为我无法手动添加sqlite3 dll?(我得到了令人讨厌的“对更高版本的引用或不兼容的程序集无法添加到项目中”错误)。 SQL Phone for Windows phone被添加到参考文件中。

1 个答案:

答案 0 :(得分:0)

SQLiteAsyncConnection conn = new SQLiteAsyncConnection(Path.Combine(ApplicationData.Current.LocalFolder.Path, "people.db"), true);

下一个打开连接

await conn.OpenAsync();
string empPersionallInfo = "create table if not exists EmpInfo" + "(no int," + "name varchar(20))";
await conn.ExecuteStatementAsync(empPersionallInfo);