如果我以非管理员身份(例如来宾帐户)登录 Windows 8,此数据库创建代码会失败吗?如果是这样,我该如何更改它适用于非管理员用户:
protected List<Order> orders;
string dbName;
#region Constructors
public RestaurantRepository()
{
Initialize();
}
protected void Initialize()
{
dbName = "db_sqlite-net.db3";
// check the database, if it doesn't exist, create it
CheckAndCreateDatabase(dbName);
}
#endregion
#region Database
protected string GetDBPath()
{
string dbRootPath = Windows.Storage.ApplicationData.Current.LocalFolder.Path;
return Path.Combine(dbRootPath, "menufinderwin8.db");
}
// This method checks to see if the database exists, and if it doesn't, it creates
// it and inserts some data
protected void CheckAndCreateDatabase(string dbName)
{
// create a connection object. if the database doesn't exist, it will create
// a blank database
SQLiteAsyncConnection conn = new SQLiteAsyncConnection(GetDBPath());
conn.CreateTableAsync<Order>();
conn.CreateTableAsync<Order>();
conn.CreateTableAsync<OrderDetail>();
conn.CreateTableAsync<Product>();
conn.CreateTableAsync<Restaurant>();
//using (SQLiteConnection db = new SQLiteConnection(GetDBPath()))
//{
// create the tables
// db.CreateTable<Order>();
//db.CreateTable<OrderDetail>();
//db.CreateTable<Product>();
//db.CreateTable<Restaurant>();
// close the connection
//db.Close();
//}
}