如何使用连接查询中的数据在 Sharepoint 中创建数据视图?
我在 Sharepoint 中有 3 个列表。
我想创建一个由 3 个表连接而成的数据视图。
Table1 与 FieldA 上的 Table2 连接 表 2 在 FieldB 上联接到表 3,
表 1 在 FieldA 中具有重复值,因此我只需返回一个值即可与表 2 联接。
在 Access 中我的查询如下所示: 选择不同的 WRK_InputWorkOrders.WorkOrder、Production1.[零件编号]、Production1.[工单]、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.[工单]) ON StationItems.Item = Production1.[零件编号] WHERE (((WRK_InputWorkOrders.Status)<>“已关闭”));
有没有办法为数据视图编写类似 sql 的查询?
我有 Sharepoint Designer 2007 和 Access。
目标是获取用户可以在 Internet Explorer 中查看的报告。 我尝试过使用此方法。 但它返回重复的记录 我发现此建议。 它建议使用 XPath 过滤器 not(@yourvalue = previous-sibling::dfs:YourRepeatingRowName/@yourvalue)
但无法让它工作。 我不知道要输入什么作为 YourRepeatingRowName
我发现 此链接。 有谁知道它是否可以用来执行这样的连接?
I have 3 Lists in Sharepoint.
I want to create a dataview that is a join of 3 tables.
Table1 is joined with Table2 on FieldA
Table 2 is joined to Table3 on FieldB
Table1 has duplicate values in FieldA so I need to only return one value to join with Table2.
In Access my query looks like this:
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)<>"closed"));
Is there a way to write sql-like queries for dataviews?
I have Sharepoint Designer 2007 and Access.
The goal is to get a report that a user can view in Internet Explorer.
I have tried using this method. But it returns duplicate records
I found this suggestion. It suggests using an XPath Filter
not(@yourvalue = preceding-sibling::dfs:YourRepeatingRowName/@yourvalue)
But wasn't able to get it to work. I don't know what to enter as YourRepeatingRowName
I found this link. Does anyone know if it can be used to perform such a join?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您的问题更多的是 ADO.NET 问题。 不幸的是,ADO.NET 没有一种简单的方法来做到这一点,这就是为什么像amboa Solutions这样的公司构建他们的交叉列表Web部件:
http://store.bamboosolutions.com/pc- 42-1-cross-list-web-part.aspx
否则我会尝试使用 LINQ 来查询表。 这样做你可能会更幸运。
这是 MS 提供的 JOIN 查询的示例(我只更改了前两行 DataTable 来表示使用 SPListItemCollection 对象填充 DataTable)
Your question is more of an ADO.NET question. Unfortunately ADO.NET doesn't have an easy way to do this, which is why companies like bamboo Solutions builds theirCross List Web Part:
http://store.bamboosolutions.com/pc-42-1-cross-list-web-part.aspx
Otherwise I would attempt to use LINQ to query the tables. You might have more luck doing that.
Here is an example of a JOIN query provided by MS (I only changed the first two DataTable lines to represent filling a DataTable with an SPListItemCollection object)
Microsoft 有一个视频演示和一篇文章,可能正是您想要的:
在单个数据视图中显示来自多个源的数据
http://office.microsoft.com/en-us/sharepointdesigner/HA103511401033。 aspx
使用 Microsoft Office SharePoint Designer 2007,您可以链接两个或多个包含相关数据的数据源,然后创建一个数据视图来显示这些链接数据源中的数据。
Microsoft has a video demo and a writeup that may be just what you want:
Display data from multiple sources in a single Data View
http://office.microsoft.com/en-us/sharepointdesigner/HA103511401033.aspx
With Microsoft Office SharePoint Designer 2007, you can link two or more data sources that contain related data and then create a single Data View that displays data from those linked data sources.
您想在 SharePoint Designer 中显示查询结果吗? 我相信SPD已经合并了数据源。 调查一下。
you want to show the query result in SharePoint Designer? I believe, SPD has merged data sources. Look into that.
我发现第三部分添加了
我无法使用它,因为我当前正在运行基本版使用内部数据库的 Sharepoint 版本。
I found this third part add on
I can't use it because I am currently running the basic Sharepoint version that uses the internal database.
我已经做了类似的事情,但我无法使用数据视图。 我最终编写了一个自定义 Web 部件来完成此操作。 方法是:
SPQuery
对象获取每个列表的SPListItemCollection
。 使用 CAML 查询来限制返回的项目。SPListItemCollection
对象的GetDataTable()
方法检索每个列表的 ADO.NETDataTable
对象。DataSet
对象。DataList
或Repeater
或其他任何方式呈现数据。下面是一些显示大致流程的代码:
I've done something like this, but I wasn't able to use a dataview. I ended up writing a custom web part to do it. The approach was:
SPQuery
object to get anSPListItemCollection
for each list. Use the CAML query to restrict the items returned.SPListItemCollection
object'sGetDataTable()
method to retrieve an ADO.NETDataTable
object for each list.DataSet
object.DataList
orRepeater
or whatever.Here's some code that shows the broad strokes: