老师,我以下代码写在窗口表的组件事件中的,上个月用得还好好的,现在点击时总提示查询超时,如图1
If Forms("资产折旧明细").Controls("加工日期1").Text = Nothing AndAlso Forms("资产折旧明细").Controls("加工日期2").Text = Nothing Then
MessageBox.Show("使用月份不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
Return
Else
Dim dr As Date = Forms("资产折旧明细").Controls("加工日期1").Text
Dim dr1 As Date = Forms("资产折旧明细").Controls("加工日期2").Text
Dim cmd As New SQLC ommand
cmd.C
cmd.C ommandText = "U PDATE a se t a.制造费用_设备折旧 = b.本月折旧 / c.加工时间 * a.加工时间 from 工序跟踪表 as a left join 资产折旧明细 as b on a.月份 = b.月份 and a.使用设备 = b.资产编号 and b.折旧类型 = '按设备算' inner join (S elect 月份,使用设备 , sum(加工时间) as 加工时间 From 工序跟踪表 g roup by 月份,使用设备) as c on a.月份 = c.月份 and a.使用设备 = c.使用设备 and a.实际加工日期 >= '" & dr & "'and a.实际加工日期 <= '" & dr1 & "'"
cmd.E xecuteNonQuery()
Dim cmd1 As New SQL Command
cmd1.C
cmd1.C ommandText = "UP DATE a1 S et a1.制造费用_其他折旧 = b1.本月折旧 / c1.加工时间 * a1.加工时间 From (S elect 月份, Sum(本月折旧) As 本月折旧 From 资产折旧明细 w here 折旧类型 = '按汇总算' group by 月份) as b1 ,工序跟踪表 as a1,(S elect 月份, sum(加工时间) as 加工时间 From 工序跟踪表 group by 月份 ) as c1 W here a1.月份 = b1.月份 and a1.月份=c1.月份 and a1.实际加工日期 >= '" & dr & "'and a1.实际加工日期 <= '" & dr1 & "'"
cmd1.E xecuteNonQuery()
End If
此主题相关图片如下:1.png

此主题相关图片如下:2.png

[此贴子已经被作者于2024/5/6 20:10:44编辑过]