Foxtable(狐表)用户栏目专家坐堂 → 代码修改


  共有9388人关注过本帖树形打印复制链接

主题:代码修改

帅哥哟,离线,有人找我吗?
明丰
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:558 积分:4352 威望:0 精华:2 注册:2011/4/18 8:27:00
代码修改  发帖心情 Post By:2011/9/3 20:53:00 [显示全部帖子]

当同时删除多行时,出错:

 

错误代码位置:表,货品资料,BeforeDeleteDataRow

System.NullReferenceException: 未将对象引用设置到对象的实例。
   在 UserCode.BeforeDeleteDataRow(DataRowEventArgs e)

 

 

请问下面代码如何修改?

 

Dim d1 As String = CurrentTable.Current("一级类别") '

Dim d2 As String = CurrentTable.Current("二级类别")
Dim d3 As String = CurrentTable.Current("三级类别")
Dim d4 As String = CurrentTable.Current("四级类别")
Dim d5 As String = CurrentTable.Current("五级类别")
Dim d6 As String = CurrentTable.Current("六级类别")
Dim dr1 As List(of DataRow) = e.DataTable.Select("一级类别 Like '" & d1 & "'") '

Dim dr2 As List(of DataRow) = e.DataTable.Select("一级类别 Like '" & d1 & "'And 二级类别 Like '" & d2 & "'")
Dim dr3 As List(of DataRow) = e.DataTable.Select("一级类别 Like '" & d1 & "'And 二级类别 Like '" & d2 & "'And 三级类别 Like '" & d3 & "'")
Dim dr4 As List(of DataRow) = e.DataTable.Select("一级类别 Like '" & d1 & "'And 二级类别 Like '" & d2 & "'And 三级类别 Like '" & d3 & "'And 四级类别 Like '" & d4 & "'")
Dim dr5 As List(of DataRow) = e.DataTable.Select("一级类别 Like '" & d1 & "'And 二级类别 Like '" & d2 & "'And 三级类别 Like '" & d3 & "'And 四级类别 Like '" & d4 & "'And 五级类别 Like '" & d5 & "'")
Dim dr6 As List(of DataRow) = e.DataTable.Select("一级类别 Like '" & d1 & "'And 二级类别 Like '" & d2 & "'And 三级类别 Like '" & d3 & "'And 四级类别 Like '" & d4 & "'And 五级类别 Like '" & d5 & "'And 六级类别 Like '" & d6 & "'")
Dim d7 As String = "该行包含类别, 是否删除?"
If (dr6 IsNot Nothing And dr6.count = 1) OrElse (dr5 IsNot Nothing And dr5.count = 1) OrElse (dr4 IsNot Nothing And dr4.count = 1) OrElse (dr3 IsNot Nothing And dr3.count = 1) OrElse (dr2 IsNot Nothing And dr2.count = 1) OrElse (dr1 IsNot Nothing And dr1.count = 1) Then
If MessageBox.Show(d7,"提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question) = DialogResult.No Then
        e.Cancel= True
Else

End If
End If


 回到顶部
帅哥哟,离线,有人找我吗?
明丰
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:558 积分:4352 威望:0 精华:2 注册:2011/4/18 8:27:00
  发帖心情 Post By:2011/9/3 22:54:00 [显示全部帖子]

谢谢!

 回到顶部