如何从 sharepoint 的讨论区获取最新 10 条帖子?

发布于 2024-12-11 06:04:37 字数 120 浏览 0 评论 0原文

我正在尝试使用 SPQuery 从 sharepoint 的讨论区获取最新的 10 篇帖子。我需要阅读 [PostUrl] [Subject] [Body] [LastModifyDate]?

请有人帮帮我吗?

I am trying to get latest 10 posts from discussion board in sharepoint by using SPQuery. I need read [PostUrl] [Subject] [Body] [LastModifyDate]?

Please some one help me out?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

怎言笑 2024-12-18 06:04:37

尝试使用下面的示例代码,它适用于我的环境。

        SPSite oSite = new SPSite("http://localhost/");
        SPWeb oWeb = oSite.OpenWeb();
        SPList oList = oWeb.Lists["DiscussionBoardList"];

        SPQuery qry = new SPQuery();
        qry.RowLimit = 10;
        qry.Query = "<OrderBy><FieldRef Name='Created' Ascending='False' /></OrderBy>";
        qry.ViewFields = "<FieldRef Name='Title' /><FieldRef Name='Body' /><FieldRef Name='Modified' />";
        DataTable dt = oList.GetItems(qry).GetDataTable();

Try with below sample code, its working on my environment.

        SPSite oSite = new SPSite("http://localhost/");
        SPWeb oWeb = oSite.OpenWeb();
        SPList oList = oWeb.Lists["DiscussionBoardList"];

        SPQuery qry = new SPQuery();
        qry.RowLimit = 10;
        qry.Query = "<OrderBy><FieldRef Name='Created' Ascending='False' /></OrderBy>";
        qry.ViewFields = "<FieldRef Name='Title' /><FieldRef Name='Body' /><FieldRef Name='Modified' />";
        DataTable dt = oList.GetItems(qry).GetDataTable();
转瞬即逝 2024-12-18 06:04:37

尝试使用下面的示例代码,它适用于我的环境。

     SPSite oSite = new SPSite("http://localhost/");
     SPWeb oWeb = oSite.OpenWeb();
     SPList oList = oWeb.Lists["DiscussionBoardList"];
     SPQuery qry = new SPQuery();
     qry.RowLimit = 10;
     qry.Query = "<OrderBy><FieldRef Name='Created' Ascending='False' /></OrderBy>";
     qry.ViewFields = "<FieldRef Name='Title' /><FieldRef Name='Body' /><FieldRef Name='Modified' />";
     DataTable dt = oList.GetItems(qry).GetDataTable(); 

Try with below sample code, its working on my environment.

     SPSite oSite = new SPSite("http://localhost/");
     SPWeb oWeb = oSite.OpenWeb();
     SPList oList = oWeb.Lists["DiscussionBoardList"];
     SPQuery qry = new SPQuery();
     qry.RowLimit = 10;
     qry.Query = "<OrderBy><FieldRef Name='Created' Ascending='False' /></OrderBy>";
     qry.ViewFields = "<FieldRef Name='Title' /><FieldRef Name='Body' /><FieldRef Name='Modified' />";
     DataTable dt = oList.GetItems(qry).GetDataTable(); 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文