0

如果我以非管理员身份(例如来宾帐户)登录 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();
        //}

    }
4

1 回答 1

0

我认为只要为所有用户安装了该应用程序,它就应该可以访问自己的本地目录。我认为您无法在用户之间共享数据库,但我认为它不会失败。

让我知道结果如何,我很好奇:)

于 2012-10-05T22:46:04.873 回答