想建立一个查询语句,请问一下代码哪里出错了?
此主题相关图片如下:1234.png

Dim sd As WinForm.DateTimePicker = e.Form.Controls("StartDate")
Dim ed As WinForm.DateTimePicker = e.Form.Controls("EndDate")
If sd.Value Is Nothing OrElse ed.Value Is Nothing Then
MessageBox.Show("请输入起始日期和终止日期!","提示", MessageBoxButtons.OK ,MessageBoxIcon.Information)
e.Cancel = True
ElseIf sd.Value > ed.Value Then
MessageBox.Show("起始日期大于终止日期!","提示", MessageBoxButtons.OK ,MessageBoxIcon.Information)
e.Cancel = True
Else
Tables("产能统计_产能查询").Filter = "[生产交期] >= #" & sd.Value & "# And [生产交期] <= #" & ed.Value & "#"
Dim t As TimeSpan = ed.Value - sd.Value
Dim nms() As String = {"横机","半圆机","一","二","三","定型","四","五","手缝","整烫","四包","五包","六","七"}
Dim c As Single
Dim str As String = ""
For Each n As String In nms
c = DataTables("产能查询").Compute("Sum(e.DataRow(n))", "生产交期 >= #" & sd.Value & "# And 生产交期 <= #" & ed.Value & "#")
str = n & "产能为:" & c & ","
Next
e.form.Controls("查询结果").Text = t.Days & "天各车间产能如下:" & str.trim(",")
End If