麻烦老师继续指导一下,黄底色中有[_SortKey] < " & dr("_SortKey")提示报错! 怎么修正呢?
谢谢!
错误代码为:
System.Reflection.TargetInvocationException: 调用的目标发生了异常。 ---> System.NullReferenceException: 未将对象引用设置到对象的实例。
在 eWebSer.form792_yema_Ajax(Request rq)
--- 内部异常堆栈跟踪的结尾 ---
在 Microsoft.VisualBasic.CompilerServices.Symbols.Container.InvokeMethod(Method TargetProcedure, Object[] Arguments, Boolean[] CopyBack, BindingFlags Flags)
在 Microsoft.VisualBasic.CompilerServices.NewLateBinding.CallMethod(Container BaseReference, String MethodName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, BindingFlags InvocationFlags, Boolean ReportErrors, ResolutionFailure& Failure)
在 Microsoft.VisualBasic.CompilerServices.NewLateBinding.ObjectLateCall(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, Boolean IgnoreReturn)
在 Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateCall(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, Boolean IgnoreReturn)
在 eWebSer.Execute(String name, Object para1, Object para2, Object para3, Object para4, Object para5, Object para6, Object para7, Object para8, Object para9, Object para10, Object para11, Object para12, Object para13, Object para14, Object para15, Object para16, Object para17, Object para18, Object para19, Object para20)
在 eWebSer.RequestConfig(RequestEventArgs e, String path, String functionsName, String html, DataRow userdr)
当前代码为:
Public Sub form792_yema_Ajax(rq As Request)
Dim e As RequestEventArgs = rq.e
Dim cmd As SQLC o m mand = rq.cmd
cmd.Conn ectio nNa me = "主数据源"
cmd.Com man dText = "S ele ct Count(*) From {一人一档} where 业务类型='" & e.Values("业务类型") & "' and 作者='" & e.Values("作者") & "' "
msg(e.Values("业务类型"))
msg(cmd.CommandText)
Dim dt As DataTable
If cmd.ExecuteScalar > 0 Then
msg("000")
cmd.CommandText = "Se lect * From {一人一档} where 业务类型='" & e.Values("业务类型") & "' and 作者='" & e.Values("作者") & "' "
dt = cmd.ExecuteReader()
msg("1")
Dim dr As DataRow
msg("2")
Dim drs As List(Of DataRow)
msg("3")
msg("业务类型 = '" & e.Values("业务类型") & "' and 作者 = '" & e.Values("作者") & "'")
dr = dt.Find("业务类型 = '" & e.Values("业务类型") & "' and 作者 = '" & e.Values("作者") & "' and [_SortKey] < " & dr("_SortKey"), "[序号] Desc") '找出上一行
msg("4")
If dr Is Nothing Then '如果没有找到上一行,说明本行就是第一行
dr("目录开始页码") = 1
'dr = e.DataRow
msg("5")
Else
dr("目录开始页码") = dr("目录截止页码") + 1
End If
msg("目录开始页码" & dr("目录开始页码"))
msg("6")
drs = dt.Se lect("业务类型 = '" & e.Values("业务类型") & "' and 作者 = '" & e.Values("作者") & "' and [_SortKey] >= " & dr("_SortKey"), "[序号]")
msg("7")
For i As Integer = 1 To drs.Count - 1 '
drs(i)("目录开始页码") = drs(i - 1)("目录截止页码") + 1
msg("9")
Next
If dr.IsNull("目录开始页码") Then
dr("目录截止页码") = Nothing
msg("9")
Else
dr("目录截止页码") = dr("目录开始页码") + dr("结束页码") - 1
msg("10")
End If
msg("目录截止页码" & dr("目录截止页码"))
dr.save()
dt.Save()
msg("11")
Else
msg("111111")
End If
End Sub
如果直接去掉:[_SortKey] < " & dr("_SortKey")
此主题相关图片如下:11.png
运行输出提示如下:
错误的事件名称
System.InvalidOperationException: 当传递具有已修改行的 DataRow 集合时,更新要求有效的 UpdateCommand。
此主题相关图片如下:12.png
[此贴子已经被作者于2023/10/7 23:04:44编辑过]