请教老师,代码如下:Dim dt As Data Table = DataTables("tblInvReport")
For Each dr As DataRow In dt.DataRows
Dim Filter As String
For i As Integer = 1 To dt.DataCols.Count - 1
Filter = Filter & "[" & dt.DataCols(i).Name & "]" & " = '" & dr(dt.DataCols(i)) & "' and "
Next
Filter = Filter.TrimEnd(" and ")
MessageBox.Show(Filter)
Dim dr1 As DataRow = DataTables("表2").Find(Filter)
If dr1 Is Nothing Then '如果没有找到的话
Dim tr = Tables("表2").AddNew()
For Each dc As DataCol In DataTables("tblInvReport").DataCols
tr(dc.Name) = dr(dc.Name)
Next
Else
Continue For
End If
Next
运行后出错
此主题相关图片如下:搜狗截图20210829181537.png
两个问题:
1. 为什么TrimEnd不能删除Filter后面的字符——“ and ”,是因为语法问题还是Foxtable 2022 preview的bug? 我试了Filter = Filter.TrimEnd(" and "),Filter = Filter.TrimEnd(" ",“and”)都不行
2. 表中有日期格式字段,但是代码【Filter = Filter & "[" & dt.DataCols(i).Name & "]" & " = '" & dr(dt.DataCols(i)) & "' and "】会出现 [日期] = ‘2015-10-13’ 这样的问题,如何解决?
【备注说明】我现在用的是Foxtable 2022 preview
[此贴子已经被作者于2021/8/29 18:34:08编辑过]