【问题标题】:Create Database Tables Windows 8 Metro创建数据库表 Windows 8 Metro
【发布时间】:2012-10-05 22:15:09
【问题描述】:

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

    }

【问题讨论】:

    标签: c# sqlite microsoft-metro


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2012-08-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-17
      • 2014-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多