Dim n As Date = Date.now
Dim bh As String = Format(n,"yyyyMMddHHmmss")
If e.DataCol.Name = "创建时间" Then '如果更改的是创建时间
If e.DataRow.IsNull("创建时间") Then
e.DataRow("编号2") = Nothing
Else
If e.DataRow("编号2").StartsWith(bh) = False '如果编号的前14位不符
Dim max As String
Dim idx As Integer
Dim d As Date = cdate(format(e.DataRow("创建时间"),"yyyy-MM-dd HH:mm:ss"))
max = e.DataTable.SQLCompute("Max(编号2)","创建时间 >= #" & d & "# And 创建时间 < #" & d.AddSeconds(1) & "# and [_Identify] <> " & e.DataRow("_Identify")) '取得该天的最大编号
If max > "" Then '如果存在最大编号
idx = CInt(max.SubString(15,3)) + 1 '获得最大编号的后三位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
e.DataRow("编号2") = bh & "-" & Format(idx,"000")
End If
End If
End If
但当SQLCompute 改为Compute 的时候却又一切正常!
[此贴子已经被作者于2019/3/19 22:15:47编辑过]