在报表中插入表时,会填充所有记录,但文本框中的相同数据不会填充所有记录吗?

时间:2015-01-23 21:49:22

标签: c# sql reportviewer

我正在设计一个报告,首先关闭此报告是通过GUI idk生成的,如果这会产生任何影响,我通过向导设计了一个新报告,而不是将该报告附加到报告查看器,最后得到了以下代码:

 private void PrintAllBag_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'corsicanaNetWeightDataSet11.Net_Weight_Master_Data_Report1' table. You can move, or remove it, as needed.
            this.Net_Weight_Master_Data_Report1TableAdapter.Fill(this.corsicanaNetWeightDataSet11.Net_Weight_Master_Data_Report1);

            this.reportViewer1.RefreshReport();

        }

用于填充数据集的查询是:

SELECT        TOP (100) PERCENT [Net Weight Master Data].[Unit UPC Base Item], [Net Weight Master Data].[Production Line], [Production Lines].[Production Line Description], 
                         [Net Weight Master Data].[Preset Number], [Net Weight Master Data].[Weight Factor], [Net Weight Master Data].Piece, [Net Weight Master Data].[Pcs Per Unit], 
                         [Net Weight Master Data].[Upper Limit Unit], [Net Weight Master Data].[Upper Limit Factor], [Net Weight Master Data].[Label Wt (g)], 
                         [Net Weight Master Data].[Tare Wt (g)], [Net Weight Master Data].[Constant Tare Wt (g)], [Net Weight Master Data].[Pkg Length (mm)], 
                         [Net Weight Master Data].[Film Product Code], [Net Weight Master Data].[Film Width (mm)], [Net Weight Master Data].[Forming Tube (mm)], 
                         [Net Weight Master Data].[Type of Jaws], [Net Weight Master Data].[Last Updated], [Maximum Allowable Variations].[MAV (g)], 
                         CASE WHEN [Upper Limit Unit] != 'g' THEN ([Label Wt (g)] / [Pcs Per Unit]) END AS [PieceWeight(g)], 
                         ([Maximum Allowable Variations].[MAV (g)] - [Production Lines].[Scale Deviation Factor] - [Net Weight Master Data].[Tare Variation Factor (g)]) 
                         / NULLIF ([Net Weight Master Data].[Weight Factor], 0) AS UL1, 
                         ([Maximum Allowable Variations].[MAV (g)] - [Production Lines].[Scale Deviation Factor] - [Net Weight Master Data].[Tare Variation Factor (g)]) 
                         / NULLIF ([Net Weight Master Data].[Weight Factor], 0) 
                         - CAST(([Maximum Allowable Variations].[MAV (g)] - [Production Lines].[Scale Deviation Factor] - [Net Weight Master Data].[Tare Variation Factor (g)]) 
                         / NULLIF ([Net Weight Master Data].[Weight Factor], 0) AS Int) AS UL2, CASE WHEN [Package Type] IS NOT NULL 
                         THEN ([mav (g)] - [scale deviation factor] - [tare variation factor (g)]) / NULLIF ([weight factor], 0) 
                         WHEN (dbo.[Maximum Allowable Variations].[MAV (g)] - dbo.[Production Lines].[Scale Deviation Factor] - dbo.[Net Weight Master Data].[Tare Variation Factor (g)]) 
                         / NULLIF (dbo.[Net Weight Master Data].[Weight Factor], 0) 
                         - CAST((dbo.[Maximum Allowable Variations].[MAV (g)] - dbo.[Production Lines].[Scale Deviation Factor] - dbo.[Net Weight Master Data].[Tare Variation Factor (g)]) 
                         / NULLIF (dbo.[Net Weight Master Data].[Weight Factor], 0) AS Int) 
                         = 0 THEN CAST((dbo.[Maximum Allowable Variations].[MAV (g)] - dbo.[Production Lines].[Scale Deviation Factor] - dbo.[Net Weight Master Data].[Tare Variation Factor (g)])
                          / NULLIF (dbo.[Net Weight Master Data].[Weight Factor], 0) AS Int) 
                         WHEN (dbo.[Maximum Allowable Variations].[MAV (g)] - dbo.[Production Lines].[Scale Deviation Factor] - dbo.[Net Weight Master Data].[Tare Variation Factor (g)]) 
                         / NULLIF (dbo.[Net Weight Master Data].[Weight Factor], 0) 
                         - CAST((dbo.[Maximum Allowable Variations].[MAV (g)] - dbo.[Production Lines].[Scale Deviation Factor] - dbo.[Net Weight Master Data].[Tare Variation Factor (g)]) 
                         / NULLIF (dbo.[Net Weight Master Data].[Weight Factor], 0) AS Int) > 0 AND 
                         (dbo.[Maximum Allowable Variations].[MAV (g)] - dbo.[Production Lines].[Scale Deviation Factor] - dbo.[Net Weight Master Data].[Tare Variation Factor (g)]) 
                         / NULLIF (dbo.[Net Weight Master Data].[Weight Factor], 0) 
                         - CAST((dbo.[Maximum Allowable Variations].[MAV (g)] - dbo.[Production Lines].[Scale Deviation Factor] - dbo.[Net Weight Master Data].[Tare Variation Factor (g)]) 
                         / NULLIF (dbo.[Net Weight Master Data].[Weight Factor], 0) AS Int) 
                         < 0.51 THEN CAST((dbo.[Maximum Allowable Variations].[MAV (g)] - dbo.[Production Lines].[Scale Deviation Factor] - dbo.[Net Weight Master Data].[Tare Variation Factor (g)])
                          / NULLIF (dbo.[Net Weight Master Data].[Weight Factor], 0) AS Int) 
                         + [Rounding Factor1] ELSE CAST((dbo.[Maximum Allowable Variations].[MAV (g)] - dbo.[Production Lines].[Scale Deviation Factor] - dbo.[Net Weight Master Data].[Tare Variation Factor (g)])
                          / NULLIF (dbo.[Net Weight Master Data].[Weight Factor], 0) AS Int) + [Rounding Factor2] END AS UL3, 
                         CASE WHEN [package type] = 'Bar' THEN 10 WHEN [upper limit unit] != 'g' THEN ([label wt (g)] / [pcs per unit]) * ([upper limit factor]) 
                         WHEN [upper limit unit] = 'g' THEN CASE WHEN [package type] IS NOT NULL THEN ([mav (g)] - [scale deviation factor] - [tare variation factor (g)]) 
                         / NULLIF ([weight factor], 0) 
                         WHEN (dbo.[maximum allowable variations].[mav (g)] - dbo.[production lines].[scale deviation factor] - dbo.[net weight master data].[tare variation factor (g)]) 
                         / NULLIF (dbo.[net weight master data].[weight factor], 0) 
                         - CAST((dbo.[maximum allowable variations].[mav (g)] - dbo.[production lines].[scale deviation factor] - dbo.[net weight master data].[tare variation factor (g)]) 
                         / NULLIF (dbo.[net weight master data].[weight factor], 0) AS INT) 
                         = 0 THEN CAST((dbo.[maximum allowable variations].[mav (g)] - dbo.[production lines].[scale deviation factor] - dbo.[net weight master data].[tare variation factor (g)]) 
                         / NULLIF (dbo.[net weight master data].[weight factor], 0) AS INT) 
                         WHEN (dbo.[maximum allowable variations].[mav (g)] - dbo.[production lines].[scale deviation factor] - dbo.[net weight master data].[tare variation factor (g)]) 
                         / NULLIF (dbo.[net weight master data].[weight factor], 0) 
                         - CAST((dbo.[maximum allowable variations].[mav (g)] - dbo.[production lines].[scale deviation factor] - dbo.[net weight master data].[tare variation factor (g)]) 
                         / NULLIF (dbo.[net weight master data].[weight factor], 0) AS INT) > 0 AND 
                         (dbo.[maximum allowable variations].[mav (g)] - dbo.[production lines].[scale deviation factor] - dbo.[net weight master data].[tare variation factor (g)]) 
                         / NULLIF (dbo.[net weight master data].[weight factor], 0) 
                         - CAST((dbo.[maximum allowable variations].[mav (g)] - dbo.[production lines].[scale deviation factor] - dbo.[net weight master data].[tare variation factor (g)]) 
                         / NULLIF (dbo.[net weight master data].[weight factor], 0) AS INT) 
                         < 0.51 THEN CAST((dbo.[maximum allowable variations].[mav (g)] - dbo.[production lines].[scale deviation factor] - dbo.[net weight master data].[tare variation factor (g)])
                          / NULLIF (dbo.[net weight master data].[weight factor], 0) AS INT) 
                         + [rounding factor1] ELSE CAST((dbo.[maximum allowable variations].[mav (g)] - dbo.[production lines].[scale deviation factor] - dbo.[net weight master data].[tare variation factor (g)])
                          / NULLIF (dbo.[net weight master data].[weight factor], 0) AS INT) + [rounding factor2] END * ([weight factor]) END AS [UpperLimit(g)], 
                         CASE WHEN [upper limit unit] = 'g' THEN CASE WHEN [package type] IS NOT NULL THEN ([mav (g)] - [scale deviation factor] - [tare variation factor (g)]) 
                         / NULLIF ([weight factor], 0) 
                         WHEN (dbo.[maximum allowable variations].[mav (g)] - dbo.[production lines].[scale deviation factor] - dbo.[net weight master data].[tare variation factor (g)]) 
                         / NULLIF (dbo.[net weight master data].[weight factor], 0) 
                         - CAST((dbo.[maximum allowable variations].[mav (g)] - dbo.[production lines].[scale deviation factor] - dbo.[net weight master data].[tare variation factor (g)]) 
                         / NULLIF (dbo.[net weight master data].[weight factor], 0) AS INT) 
                         = 0 THEN CAST((dbo.[maximum allowable variations].[mav (g)] - dbo.[production lines].[scale deviation factor] - dbo.[net weight master data].[tare variation factor (g)]) 
                         / NULLIF (dbo.[net weight master data].[weight factor], 0) AS INT) 
                         WHEN (dbo.[maximum allowable variations].[mav (g)] - dbo.[production lines].[scale deviation factor] - dbo.[net weight master data].[tare variation factor (g)]) 
                         / NULLIF (dbo.[net weight master data].[weight factor], 0) 
                         - CAST((dbo.[maximum allowable variations].[mav (g)] - dbo.[production lines].[scale deviation factor] - dbo.[net weight master data].[tare variation factor (g)]) 
                         / NULLIF (dbo.[net weight master data].[weight factor], 0) AS INT) > 0 AND 
                         (dbo.[maximum allowable variations].[mav (g)] - dbo.[production lines].[scale deviation factor] - dbo.[net weight master data].[tare variation factor (g)]) 
                         / NULLIF (dbo.[net weight master data].[weight factor], 0) 
                         - CAST((dbo.[maximum allowable variations].[mav (g)] - dbo.[production lines].[scale deviation factor] - dbo.[net weight master data].[tare variation factor (g)]) 
                         / NULLIF (dbo.[net weight master data].[weight factor], 0) AS INT) 
                         < 0.51 THEN CAST((dbo.[maximum allowable variations].[mav (g)] - dbo.[production lines].[scale deviation factor] - dbo.[net weight master data].[tare variation factor (g)])
                          / NULLIF (dbo.[net weight master data].[weight factor], 0) AS INT) 
                         + [rounding factor1] ELSE CAST((dbo.[maximum allowable variations].[mav (g)] - dbo.[production lines].[scale deviation factor] - dbo.[net weight master data].[tare variation factor (g)])
                          / NULLIF (dbo.[net weight master data].[weight factor], 0) AS INT) + [rounding factor2] END * ([weight factor]) END AS [LowerLimit(g)], 
                         CASE WHEN [Package Type] = 'Bar' THEN ([Net Weight Master Data].[Label Wt (g)]) - ([Maximum Allowable Variations].[MAV (g)]) 
                         + ([Net Weight Master Data].[Tare Wt (g)]) 
                         WHEN dbo.[Net Weight Master Data].[Package Type] = '10 Pack' THEN [Label Wt (g)] - [MAV (g)] + [tare Wt (g)] + 2.5 ELSE [Label Wt (g)] - [Maximum Allowable Variations].[MAV (g)]
                          + [tare Wt (g)] + 5 END AS [Repair Min Wt (g)], ItemDesc.[Item Description]
FROM            [Net Weight Master Data] LEFT OUTER JOIN
                         [Production Lines] ON [Net Weight Master Data].[Production Line] = [Production Lines].[Production Line] INNER JOIN
                         [Maximum Allowable Variations] ON [Net Weight Master Data].[Label Wt (g)] = [Maximum Allowable Variations].[Labeled Quantity (g)] LEFT OUTER JOIN
                         ItemDesc ON [Net Weight Master Data].[Unit UPC Base Item] = ItemDesc.[Unit UPC Base Item]
ORDER BY [Net Weight Master Data].[Unit UPC Base Item], [Net Weight Master Data].[Production Line]

正如您所看到的,我正在进行全选,并且数据集中没有涉及参数,但我的报告仍然只显示第一条记录,我不确定这是否是与reportviewer或报表设计器的约束,哪里可以我修改,以便报告显示所有记录。总共有2373条记录,我只想点击顶部的导航疼痛然后去下一个和下一个

我的表单图片请点击此处link

任何帮助都非常感谢thnks !!!

2 个答案:

答案 0 :(得分:0)

假设[净重主数据]表中有2373条记录,那么很可能是查询中的INNER JOIN限制了结果。尝试从查询中删除INNER JOIN并再次运行它。如果你的问题没有更多的背景,那么很难给出更具体的答案。

我还建议从SELECT中删除TOP(100)PERCENT,因为它在您的查询中没有做任何事情。

答案 1 :(得分:0)

我遇到了类似的问题,我在stackoverflow的帮助下解决了这个问题,所以就像你在问题中所说的那样,报表中的表能够重复所有记录而不是文本框,你可以通过以下方式完成任务以下步骤:

  1. 确保为报告定义了数据集。
  2. 在报告中添加“表格”控件。为了迭代数据集中的行,似乎需要这样做。
  3. 从表格中删除标题行和两个默认列,这样您就会留下一行包含一列。
  4. 将表格展开为布局的宽度,并使其与“自由格式”布局所需的一样高。
  5. 默认情况下,表格单元格中有一个TextBox。右键单击空表格单元格,然后选择“删除”以删除该TextBox。
  6. 将“矩形”控件拖到空表格单元格中。它似乎自动“停靠”到表格单元格的宽度/高度。
  7. 现在,您应该可以将DataSet(TextBoxes等)中的字段拖动到Rectangle中以生成所需的布局。
  8. 希望这有帮助:)