简体   繁体   English

刷新ReportViewer中数据集中的字段

[英]Refresh fields in Dataset in ReportViewer

I have a WinForms application, written in VS2012. 我有一个WinForms应用程序,用VS2012编写。 It sources data from a View on my SQL Server database. 它从我的SQL Server数据库上的View中获取数据。 I added a new column to my view, but, can't find a way to get the ReportViewer dataset to see the new column. 我在视图中添加了一个新列,但是,无法找到一种方法来获取ReportViewer数据集以查看新列。

In the ReportData panel, I have attempted: 在ReportData面板中,我尝试过:

Right Click data source, and click Refresh. 右键单击数据源,然后单击“刷新”。 Right Click data set, and click Refresh 右键单击数据集,然后单击“刷新”

Both do not get the new column to show in the list of available columns. 两者都没有在可用列的列表中显示新列。

How do I get the column to show in my report designer within VS2012? 如何在VS2012中的报表设计器中显示该列?

Since I just had the same problem and none of the suggested answers helped... 因为我只是遇到了同样的问题而没有一个建议的答案有帮助......

You can add the field in XML as well. 您也可以在XML中添加该字段。 Right click on the report and chose Open with... , select XML (Text)-Editor . 右键单击报告并选择Open with... ,选择XML (Text)-Editor Now look for the tag <DataSets> and add a new <Field> inside the <Fields> branch. 现在查找标记<DataSets>并在<Fields>分支中添加新的<Field> For example, you just added the column Test to your DataSet, which previously contained FieldName1 and FieldName2 . 例如,您刚刚将Test列添加到DataSet中,以前包含FieldName1FieldName2 You can edit the XML as such: 您可以这样编辑XML:

<DataSets>
  <DataSet Name="YourDataSet">
    <Fields>
      <Field Name="FieldName1">
       <DataField>FieldName1</DataField>
       <rd:TypeName>System.YourType</rd:TypeName>
      </Field>
      <Field Name="FieldName2">
       <DataField>FieldName2</DataField>
       <rd:TypeName>System.YourType</rd:TypeName>
      </Field>
      <Field Name="Test">
       <DataField>Test</DataField>
       <rd:TypeName>System.YourType</rd:TypeName>
      </Field>
    </Fields>
  </DataSet>
</DataSets>

Now save the XML and open it again in the report designer. 现在保存XML并在报表设计器中再次打开它。 You now should be able to select your new field and add it to the report. 您现在应该能够选择新字段并将其添加到报表中。

In the Report Data window, do you see a "Datasets" section? 在“报告数据”窗口中,您是否看到“数据集”部分? Try refreshing these datasets. 尝试刷新这些数据集。 Also make sure the sources are binded properly and with the right name. 还要确保源正确绑定并使用正确的名称。

I usually delete the xsd file containing the dataset and recreated it from scratch. 我通常会删除包含数据集的xsd文件,并从头开始重新创建。 Then you can refresh ReportData panel to see the new column. 然后,您可以刷新ReportData面板以查看新列。

I went through the same problem. 我遇到了同样的问题。

I managed to settle with the following process: In your project locate the file ".xsd" which makes reference to the whole of Data used in the report (DataSource). 我设法解决了以下过程:在您的项目中找到文件“.xsd”,它引用了报告中使用的整个数据(DataSource)。

After finding this aquivo in your solcution open the way designer by double-clicking this. 在你的解决方案中找到这个aquivo后,双击这个打开设计师的方式。

This file is your data source it can contain your queries, tables, procedures, search for your query related to the report you want to update (DataSet) with a click of the right mouse button select the "Configure ..." option in the next resulting window select your query fields should appear on the block forward, then it is just click the finish. 此文件是您的数据源,它可以包含您的查询,表格,程序,搜索与您要更新的报表相关的查询(DataSet),只需单击鼠标右键选择“配置...”选项即可下一个结果窗口选择你的查询字段应该出现在块前进,然后它只是单击完成。

Recalling that made this process with storage procedures, and this was already updated in my database. 回顾一下这个过程是用存储过程完成的,而且这已经在我的数据库中更新了。

Not sure if this is on the right track, but I know that when using a .dbml designer to connect with a database, when I change the schema of an object in the DB, I have to refresh the server browser, drop the object on design surface and re-add the object to the design surface. 不确定这是否在正确的轨道上,但我知道当使用.dbml设计器连接数据库时,当我更改数据库中对象的模式时,我必须刷新服务器浏览器,删除对象设计表面并将对象重新添加到设计图面。 It doesn't automatically update the schema in the dbml. 它不会自动更新dbml中的架构。

1. Delete all contents and folder from your project BIN and Obj folder 1.从项目BIN和Obj文件夹中删除所有内容和文件夹

  1. Reopen your visual studio as well as your project. 重新打开您的视觉工作室以及您的项目。

  2. Then press Ctrl + Alt + D to open Report Data Window 然后按Ctrl + Alt + D打开报表数据窗口

  3. Expanding Data Source Refresh your desired one 扩展数据源刷新您想要的数据源

  4. Expanding Data set Refresh your desired one 扩展数据集刷新您想要的数据集

It is ok now. 现在好了。 Happy Coding. 快乐的编码。

转到属性,新选择源类

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM