美好的一天,
我正在使用SQL中的一个强大功能,即Sql Query Notification。 我试过它并且效果很好但是当我已经使用了聚合函数Sum时,我得到了错误 **
“在窗口处理之前不能调用或开始控制 已创建“..
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%确定问题出在我的查询中..请 救命.. 谢谢你:))
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