2012-10-05 68 views
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(); 
     //} 

    } 

回答

0

我覺得只要安裝該應用程序爲所有用戶,應該有機會獲得它自己的本地目錄。我不認爲你可以在用戶之間共享數據庫,但我不認爲它會失敗。

讓我知道結果如何,我很好奇:)

+0

你說得對。權限不重要。 –