版主,我用Dim path As String = ProjectPath & "RemoteFiles\"
For Each File As String In FileSys.GetFiles(path)
Dim name As String = filesys.GetName(file)
Dim fdr As DataRow = DataTables("表A").Find("资料名称 = '" & name & "'")
If fdr IsNot Nothing Then
fdr("缓存")="1"
else '难道是这里有什么错误?
fdr("缓存")="0"
End If
Next
提示:未将对象引用设置到对象的实例。
这个哪里错了?
用
Dim path As String = ProjectPath & "RemoteFiles\"
For Each File As String In FileSys.GetFiles(path)
Dim name As String = filesys.GetName(file)
Dim fdr As DataRow = DataTables("表A").Find("资料名称 = '" & name & "'")
If fdr IsNot Nothing Then
fdr("缓存")="3"
End If
Next
DataTables("表A").ReplaceFor("缓存", 0, "缓存=‘’") '你的代码是 缓存=1,实际上即使不存在缓存,数据表中也没有等于1的值,所以我改为判断是否是空值
DataTables("表A").ReplaceFor("缓存", 1, "缓存 = 3")
没有错误提示,但是当本地没有缓存文件时,“缓存”列的值还是不等于0.
[此贴子已经被作者于2017/8/2 7:58:33编辑过]