5

我在 Sharepoint 中有 3 个列表。

我想创建一个连接 3 个表的数据视图。

Table1 与 FieldA 上的 Table2 连接 表 2 与 FieldB 上的 Table3 连接

Table1 在 FieldA 中有重复的值,所以我只需要返回一个值来加入 Table2。

在 Access 中,我的查询如下所示:SELECT DISTINCT WRK_InputWorkOrders.WorkOrder, Production1.[Part Number], Production1.[Work Order], Production1.Location, StationItems.Station, Production1.Description, Production1.Revision, WRK_InputWorkOrders.Status FROM StationItems INNER JOIN (WRK_InputWorkOrders INNER JOIN Production1 ON WRK_InputWorkOrders.WorkOrder = Production1.[Work Order]) ON StationItems.Item = Production1.[Part Number] WHERE (((WRK_InputWorkOrders.Status)<>"已关闭"));

有没有办法为数据视图编写类似 sql 的查询?

我有 Sharepoint Designer 2007 和 Access。

目标是获取用户可以在 Internet Explorer 中查看的报告。我试过使用这种方法。但它返回重复的记录,我发现了这个建议。它建议不要使用 XPath 过滤器(@yourvalue = previous-sibling::dfs:YourRepeatingRowName/@yourvalue)

但无法让它工作。我不知道作为 YourRepeatingRowName 输入什么

我找到了这个链接。有谁知道它是否可以用来执行这样的加入?

4

5 回答 5

1

您的问题更像是 ADO.NET 问题。不幸的是,ADO.NET 没有简单的方法来做到这一点,这就是为什么像竹解决方案这样的公司构建他们的交叉列表 Web 部件: http ://store.bamboosolutions.com/pc-42-1-cross-list-web-零件.aspx

否则我会尝试使用 LINQ 来查询表。你这样做可能会有更多的运气。

下面是 MS 提供的 JOIN 查询示例(我只更改了前两行 DataTable 以表示用 SPListItemCollection 对象填充 DataTable)

DataTable orders = spListCol1.ToDataTable();
DataTable details = spListCol2.ToDataTable();

var query =
    from order in orders.AsEnumerable()
    join detail in details.AsEnumerable()
    on order.Field<int>("SalesOrderID") equals
        detail.Field<int>("SalesOrderID")
    where order.Field<bool>("OnlineOrderFlag") == true
    && order.Field<DateTime>("OrderDate").Month == 8
    select new
    {
        SalesOrderID =
            order.Field<int>("SalesOrderID"),
        SalesOrderDetailID =
            detail.Field<int>("SalesOrderDetailID"),
        OrderDate =
            order.Field<DateTime>("OrderDate"),
        ProductID =
            detail.Field<int>("ProductID")
    };

DataTable orderTable = query.CopyToDataTable(); 
于 2009-01-23T21:13:59.047 回答
1

微软有一个视频演示和一篇文章,可能正是你想要的:

在单个数据视图中显示来自多个来源的数据 http://office.microsoft.com/en-us/sharepointdesigner/HA103511401033.aspx

使用 Microsoft Office SharePoint Designer 2007,您可以链接两个或多个包含相关数据的数据源,然后创建一个显示来自这些链接数据源的数据的数据视图。

于 2009-01-24T17:40:52.533 回答
0

我发现这第三部分添加

Enesys RS Data Extension 允许您从任何 SharePoint 列表中查询(检索、连接、合并...)数据,并使用结果来构建“Reporting Services”报告,就像您对任何其他数据源所做的那样。http://www.enesyssoftware.com/

我无法使用它,因为我目前正在运行使用内部数据库的基本 Sharepoint 版本。

于 2009-01-23T16:20:32.493 回答
0

想要在 SharePoint Designer 中显示查询结果?我相信,SPD 已经合并了数据源。调查一下。

于 2009-01-22T07:35:53.923 回答
0

我做过类似的事情,但我无法使用数据视图。我最终编写了一个自定义 Web 部件来完成它。方法是:

  1. 使用一个SPQuery对象SPListItemCollection为每个列表获取一个。使用 CAML 查询来限制返回的项目。
  2. 使用SPListItemCollection对象的GetDataTable()方法检索DataTable每个列表的 ADO.NET 对象。
  3. 将表添加到DataSet对象。
  4. 创建表之间的关系。
  5. 以您喜欢的方式渲染数据,使用DataListRepeater其他方式。

这是一些显示粗略笔划的代码:

protected DataTable GetDataTableFromQuery(string camlQry, SPList theList) {
  SPQuery listQry = new SPQuery();  
  listQry.Query = camlQry;  
  SPListItemCollection listItems = theList.GetItems(listQry);  
  return listItems.GetDataTable();
}

protected void BuildDataSet() {  
  // get SPList objects for the lists in questions ... left as an exercise for the dev -- call them list1, list2, and list3  
  string camlQry = "the CAML necessary to retreive the ites from list1";  
  DataTable table1 = GetDataTable(camlQry, list1);  
  table1.TableName = "Table1";  
  camlQry = "the CAML necessary to retreive the ites from list2";  
  DataTable table2 = GetDataTable(camlQry, list2);  
  table1.TableName = "Table2";  
  camlQry = "the CAML necessary to retreive the ites from list3";  
  DataTable table3 = GetDataTable(camlQry, list3);  
  table1.TableName = "Table3";  

  // now build the DataSet
  DataSet ds = new DataSet();  
  ds.Tables.Add(table1);  
  ds.Tables.Add(table2);  
  ds.Tables.Add(table3);  
  ds.Relations.Add("Table1_2", ds.Tables["Table1"].Columns["FieldA"], ds.Tables["Table2"].Columns["FieldA"]);  
  ds.Relations.Add("Table2_3", ds.Tables["Table2"].Columns["FieldB"], ds.Tables["Table3"].Columns["FieldB"]);  

  // now you can do something with these, like store them in the web part class and bind them to repeaters in the web part's Render() method
}
于 2009-04-28T17:41:03.333 回答