我需要解锁受密码保护的SQLite文件添加数据,然后通过电子邮件发送受密码保护的文件,我的所有查询和电子邮件都可以正常工作,直到我使用数据库浏览器(SQLCipher)对该文件进行密码保护为止
我一直在GitHub SQLite-Net上关注此示例,该示例
var options = new SQLiteConnectionString(databasePath, true,
key: "password");
var encryptedDb = new SQLiteAsyncConnection(options);
但是当我将var选项添加到SQLiteAsyncConnection时出现错误,错误提示
无法从SQLite.SQLiteConnectionString转换为String
private async void pickPeriod()
{
List<string> periodArray = new List<string>();
SQLitePCL.Batteries.Init();
try
{
string fileName = "fieldnames5.sql";
var databasePath = Path.Combine (Windows.Storage.ApplicationData.Current.LocalFolder.Path, fileName);
var options = new SQLiteConnectionString(databasePath, true, key: "Wi_Day!");
var conn = new SQLiteAsyncConnection(options);
{
await conn.CreateTableAsync<storeNames>();
try
{
var periodNo = await conn.QueryAsync<storeNames> ("SELECT Period FROM WkNos");
foreach (var period in periodNo)
{
string myresult = period.Period.ToString();
periodArray.Add(period.Period);
HashSet<string> set = new HashSet<string>(periodArray);
string[] result = new string[set.Count];
set.CopyTo(result);
periodArray.AddRange(result);
}
pdNumPick.Items.Clear();
pdNumPick.ItemsSource = periodArray;
}
catch
{
pdNum.Text = "<-No Data->";
}
}
}
catch
{
Debug.WriteLine("File does not exits");
}
}
我只需要解锁SQLite文件并添加数据并重新锁定