老师好:请教一个问题。
我在DataColChanged表事件中写了这样的代码:
Select Case e.DataCol.name
Case "生产日期","操作员","岗位系数"
Dim dr As DataRow = e.DataRow
If dr.IsNull("生产日期") = False AndAlso dr.IsNull("操作员") = False AndAlso dr.IsNull("岗位系数") = False Then
If e.DataTable.Compute("Count([_Identify])","岗位系数 = '" & dr("岗位系数") & "'And 操作员 = '" & dr("操作员") & "'And 生产日期 = #" & e.DataRow("生产日期") & "# ") > 1 Then
e.DataRow("岗位系数") = e.OldValue '取消输入
End If
End If
End Select
以上对已加载的数据有效,但是要对未加载的数据实现同样的功能,我按下面的方法加了SQL结果提示错误 "标准表达式中数据类型不匹配"。(岗位系数列是数值型,生产日期是日期时间型,操作员是字符型),不知道应该怎样改。
Select Case e.DataCol.name
Case "生产日期","操作员","岗位系数"
Dim dr As DataRow = e.DataRow
If dr.IsNull("生产日期") = False AndAlso dr.IsNull("操作员") = False AndAlso dr.IsNull("岗位系数") = False Then
If e.DataTable.SQLCompute("Count([_Identify])","岗位系数 = '" & dr("岗位系数") & "'And 操作员 = '" & dr("操作员") & "'And 生产日期 = #" & e.DataRow("生产日期") & "# ") > 1 Then
e.DataRow("岗位系数") = e.OldValue '取消输入
End If
End If
End Select