【问题标题】:C# Data Not Cycling Through DataGrid SQL SPC# 数据未通过 DataGrid SQL SP 循环
【发布时间】:2016-10-19 16:22:20
【问题描述】:

我在这个相当大的项目中使用 Infragistics WebDataGrid。需要发生的是当用户选择 2 个日期并且在 10 个 WebDatagrids 中的至少 1 个中显示装配编号缺陷信息时。大多数时候有2个或更多的缺陷信息。我正在将结果与旧的 VB.NET Windows 窗体应用程序进行比较。我可以成功运行 SP 并获得结果,但是,只有一个数据网格填充了结果,而不是其他应该包含信息的网格。为了安全起见,我删除了连接详细信息。提前感谢您的帮助。

C# 代码 私人无效消息框(字符串味精) { Page.Controls.Add(new LiteralControl( " window.alert('" + msg.Replace("'", "\'") + "')")); }

            private void getDefects(string workArea, WebDataGrid webDG)
            {
            if (wdpStartDate.Text == "" || wdpEndDate.Text == "")
            {
            MessageBox("You must provide values for Start Date and End Date!");
            }
            else
            {
            //Create a connection to the SQL Server on IIS01.

            //Establishes the command structure for the stored procedure Top5Defects.
            SqlCommand cmd = new SqlCommand("dbo.Top5Defects", iis01Connection);
            cmd.CommandType = CommandType.StoredProcedure;

            //Establishes the required parameters to pass to the stored procedure.
            cmd.Parameters.AddWithValue("@StartDate", wdpStartDate.Date.ToShortDateString());
            cmd.Parameters.AddWithValue("@EndDate", wdpEndDate.Date.ToShortDateString());
            cmd.Parameters.AddWithValue("@Assembly", Assemblies.CurrentValue);
            cmd.Parameters.AddWithValue("@WorkArea", workArea);
            iis01Connection.Open();
            SqlDataReader dr = cmd.ExecuteReader();
            webDG.DataSource = dr;
            webDG.DataBind();
            }
            }

            public void GetDefectHistory()
            {

            getDefects("SL", wdgSL);
            getDefects("PW", wdgPW);
            getDefects("SMT", wdgSMT);
            getDefects("SS/Wave", wdgSSWV);
            getDefects("AI", wdgAI);
            getDefects("ICT", wdgICT);
            getDefects("FT", wdgFT);
            getDefects("CC", wdgCC);
            getDefects("EM", wdgEM);
            getDefects("TC", wdgTC);
            }

            protected void btnResults_Click(object sender, EventArgs e)
            {
            GetDefectHistory();
            }

存储过程 使用 [EMS 数据库] 去 /****** 对象:StoredProcedure [dbo].[Top5Defects] 脚本日期:10/18/2016 10:15:48 PM ******/ 设置 ANSI_NULLS ON 去 设置 QUOTED_IDENTIFIER ON 去 -- =============================================== -- 作者:特伦特·亚当斯> -- 创建日期:10-13-2016 -- 描述:EMSDatabase Top Defects 的存储过程 -- =============================================== 更改程序 [dbo].[Top5Defects] @StartDate 日期时间, @EndDate 日期时间, @Assembly VARCHAR(50), @WorkArea VARCHAR(50)

            AS
            --Declare @WorkArea as VARCHAR(50)
            --Set @WorkArea ='SL'

            BEGIN
            -- SET NOCOUNT ON added to prevent extra result sets from
            -- interfering with SELECT statements.
            SET NOCOUNT ON;

            SELECT Top 5 Sum(Quantity) AS 'Sum', DefectCode As Defect, PartInvolved AS Part 
            FROM EMSDefectHistory
            WHERE DateEntered Between @StartDate AND @EndDate
                AND Assembly = @Assembly
                AND WorkArea = @WorkArea
            GROUP BY DefectCode, PartInvolved 
            ORDER BY Sum(Quantity) DESC
            END

【问题讨论】:

    标签: asp.net infragistics


    【解决方案1】:

    原来我在阅读 VB.NET 代码时是盲目的。因为功能测试 (FT) 和在线测试 (ICT) 使用不同的表,所以我需要分别为这些 FT/ICT 创建一个方法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-16
      • 2012-01-02
      • 2016-01-05
      相关资源
      最近更新 更多