老师好,项目表的主键列当初没有统一用"_SortKey"这一个,有的是“_Identify”。现在设置了下面的代码就报错了。
If e.DataTable.Name <> "数据操作日志" Then
If e.DataRow.RowState = 2 Then
' MessageBox.Show(e.DataRow.RowState)
Return
Else
' MessageBox.Show(e.DataRow.RowState)
Dim dr As DataRow = DataTables("数据操作日志").AddNew
dr("ID") = e.DataRow("_SortKey")
dr("用户") = User.Name
dr("涉及表") = e.DataTable.Name
dr("涉及列") = e.DataCol.Name
dr("涉及行") = e.DataRow("_SortKey")
dr("时间") = Date.Now
dr("操作") = """" & e.OldValue & """ 改成了 """ & e.NewValue & """"
Dim str As String = ""
For Each c As DataCol In e.DataTable.DataCols
str += c.Name & "=" & e.DataRow(c.Name) & "|"
Next
dr("原行数据") = str
End If
End If
If e.DataTable.Name <> "数据操作日志" Then
Dim dr As DataRow = DataTables("数据操作日志").AddNew
dr("ID") = e.DataRow("_SortKey")
dr("用户") = User.Name
dr("涉及表") = e.DataTable.Name
dr("涉及列") = Nothing
dr("涉及行") = e.DataRow("_SortKey")
dr("时间") = Date.Now
dr("操作") = "增加了一行"
Dim str As String = ""
For Each c As DataCol In e.DataTable.DataCols
str += c.Name & "=" & e.DataRow(c.Name) & "|"
Next
dr("原行数据") = str
End If