1

再会,

我正在使用 SQL 中的强大功能之一,即 Sql Query Notification.. 我试过了,效果很好,但是当我已经使用聚合函数 Sum 时,我收到错误消息说**

“在创建窗口句柄之前,不能在控件上调用调用或开始”..

C#

private void dependency_OnChange(object sender, SqlNotificationEventArgs e) { 
    try { 
        UIDelegate uidel = new UIDelegate(RefreshData); 
        this.Invoke(uidel, null); 
        SqlDependency dependency = (SqlDependency)sender; 
        dependency.OnChange -= dependency_OnChange; } 
    catch (Exception R) { 
        MessageBox.Show(R.Message); 
    } 
}

我对此的了解是错误来自我的查询,它使用聚合函数求和,这就是为什么。

如何在 SQL QUERY NOTIFICATION 中使用聚合函数 SUM?这是我的查询表格,请检查它..我100%确定问题出在我的查询中..请帮助..谢谢:)

SQL

SELECT SALES_ORDER.SALES_ORDER_ID AS [SALES ORDER ID],
       CUSTOMER.CUSTOMER_NAME     AS [CUSTOMER NAME],
       SALES_ORDER.OrderDate,
       SALES_ORDER.ORDERSTATUS    AS [STATUS],
       SUM(ORDERLINE.AMOUNT)      AS [TOTAL AMOUNT]
FROM   dbo.SALES_ORDER
       INNER JOIN dbo.CUSTOMER
         ON dbo.CUSTOMER.CUSTOMER_ID = dbo.SALES_ORDER.CUSTOMER_ID
       INNER JOIN dbo.ORDERLINE
         ON dbo.ORDERLINE.SALES_ORDER_ID = dbo.SALES_ORDER.SALES_ORDER_ID
WHERE  dbo.SALES_ORDER.ORDERSTATUS = 'PENDING'
        OR dbo.SALES_ORDER.ORDERSTATUS = 'COMPLETED'
        OR dbo.SALES_ORDER.ORDERSTATUS = 'PROVISIONING'
           AND dbo.ORDERLINE.OrderLineStatus = 'PENDING'
        OR dbo.ORDERLINE.OrderLineStatus = 'COMPLETED'
        OR dbo.ORDERLINE.OrderLineStatus = 'PROVISIONING'
GROUP  BY dbo.SALES_ORDER.SALES_ORDER_ID,
          dbo.CUSTOMER.CUSTOMER_NAME,
          dbo.SALES_ORDER.OrderDate,
          dbo.SALES_ORDER.ORDERSTATUS
ORDER  BY [SALES ORDER ID] DESC 
4

0 回答 0