0
如果我以非管理員身份(如來賓帳戶)登錄到Windows 8,此數據庫創建代碼是否會失敗?如果是這樣,我怎麼可以改變它的工作原理與非管理員用戶:創建數據庫表Windows 8 Metro
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();
//}
}
你說得對。權限不重要。 –