【问题标题】:Select data from local database从本地数据库中选择数据
【发布时间】:2013-01-15 21:11:49
【问题描述】:

我正在尝试获取存储在本地数据库中的数据。我正在使用这样的东西:

// Connect to the database and instantiate data context.
tablesDB = new TablesDataContext(TablesDataContext.DBConnectionString);    

// Define the query to gather all of the items.
var CategoriesTablesInDB = from CategoryItem todo in tablesDB.CategoriesTable
                                           select todo;

// Execute the query and place the results into a collection.
CategoriesTable = new ObservableCollection<CategoryItem>(CategoriesTablesInDB);

但是我的CategoriesTable在这样做之后有count = 0,而CategoriesTablesInDB里面有它的sql查询。我是 Windows Phone 新手,如果这样做是正确的方法,我不会。是我的查询有问题,还是我做得不对?

【问题讨论】:

  • @spajce 对不起,但这不是我要问的
  • 是的。我的意思是你试图在ObservableCollection 中添加项目:)
  • @spajce 好吧...我并没有尝试完全添加项目..我没有列表或任何东西。我正在尝试执行返回我项目的查询。所以我不认为遍历所有元素是可能的。
  • 我设法解决了这个问题。一切都很好,我只是有空数据库。

标签: c# windows-phone-8 local-database


【解决方案1】:

很遗憾,无法为您提供确切的答案。但是,如果您刚刚开始,您也可以尝试将数据存储在 SQLite 中而不是本地本地数据库中。它可以帮助您在未来构建跨平台应用程序,并拥有广泛的社区支持。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-02-21
    • 1970-01-01
    • 1970-01-01
    • 2012-01-01
    • 1970-01-01
    • 2011-04-07
    • 1970-01-01
    相关资源
    最近更新 更多