我尝试过用过你这个sqlite for wp8的库,没成功过,还是用原来的wp7版本访问数据库的方法;
上网找到Vici.CoolStorage.WP7.dll和Vici.Core.WP7.dll这两个dll
下面是操作思路:
//注意:先往项目添加Vici.CoolStorage.WP7.dll和Vici.Core.WP7.dll
string fn = "MNSECRET.DB";//您的数据库名称,注意放在项目根目录下,且设置生成操作为Resource,不复制
Assembly assem = Assembly.GetExecutingAssembly();
string assemeblyName=assem.FullName.Substring(0, assem.FullName.IndexOf(','));
Uri dbURi= new Uri("/" + assemeblyName + ";component/" + fn,
UriKind.Relative);
//程序第一次运行把SQLite数据库Copy到本地存储
StreamResourceInfo sr = Application.GetResourceStream(dbURi);
IsolatedStorageFile iStorage = IsolatedStorageFile.GetUserStoreForApplication();
if (!iStorage.FileExists(fn))
{
using (var outputStream = iStorage.OpenFile(fn, FileMode.CreateNew))
{
byte[] buffer = new byte[10000];
for (; ; )
{
int read = sr.Stream.Read(buffer, 0, buffer.Length);
if (read <= 0)
break;
outputStream.Write(buffer, 0, read);
}
}
}
//连接数据库
CSConfig.SetDB(fn);
//数据操作
CSGenericRecordList cslis = CSDatabase.RunQuery("SELECT* FROM CITY");//可以理解为返回一个表格
foreach (CSGenericRecord cs in cslis)
{
//取表中的每一行数据
string result= cs["数据表字段名"].ToString();
}