Foxtable(狐表)用户栏目专家坐堂 → [求助] 代码错误


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

主题:[求助] 代码错误

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


加好友 发短信
等级:三尾狐 帖子:799 积分:5921 威望:0 精华:0 注册:2018/11/3 8:24:00
[求助] 代码错误  发帖心情 Post By:2021/4/13 21:08:00 [只看该作者]


老师,以下黄色代码错在哪儿了,明明有找到记录的,就是中跳出以下IF

If e.Col.Name = "Priority" Then
    Dim cmd As new SQLCommand
    Dim dt As DataTable
    cmd.CommandText = "Se lect * From {t_SupplyEntry} Where FItemID = '" & e.Row ("FItemID") & "'and FPrioritized = 1"
      cmd.C
    Dim Values = cmd.ExecuteValues
    If Values.Count > 0 Then
        dt = cmd.ExecuteReader(True)
        
        Dim ffdr As DataRow = dt.Find("FItemID=" & e.Row("FItemID") & "")

        If ffdr Is Nothing Then
         
            
            If MessageBox.Show("该产品已经设定过优先次序了,是否需要把原来的优先次序去除,重新设定当前产品为订单优先 ?","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question) = DialogResult.Yes Then
                
                ffdr("FPrioritized")  = 0
                e.Row("Priority") = True
            Else
                e.Row("Priority") = False
            End If
           
            
            dt.Save()
        End If
    End If
End If

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


加好友 发短信
等级:超级版主 帖子:109489 积分:557107 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2021/4/13 21:12:00 [只看该作者]

Dim ffdr As DataRow = dt.Find("FItemID='" & e.Row("FItemID") & "'")

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


加好友 发短信
等级:三尾狐 帖子:799 积分:5921 威望:0 精华:0 注册:2018/11/3 8:24:00
  发帖心情 Post By:2021/4/13 21:26:00 [只看该作者]

这个也试过了,还是没有反应

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


加好友 发短信
等级:三尾狐 帖子:799 积分:5921 威望:0 精华:0 注册:2018/11/3 8:24:00
  发帖心情 Post By:2021/4/13 21:31:00 [只看该作者]


如果改成以下,找到后有出现提示如果找到,但是 Values("FPrioritized")  = 0 没有变更过来


If e.Col.Name = "Priority" Then
    Dim cmd As new SQLCommand
    Dim dt As DataTable
    cmd.CommandText = "Se lect * From {t_SupplyEntry} Where FItemID = '" & e.Row ("FItemID") & "'and FPrioritized = 1"
      cmd.C
    Dim Values = cmd.ExecuteValues
    If Values.Count > 0 Then
        dt = cmd.ExecuteReader(True)
        
            
            
            If MessageBox.Show("该产品已经设定过优先次序了,是否需要把原来的优先次序去除,重新设定当前产品为订单优先 ?","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question) = DialogResult.Yes Then
                
               Values("FPrioritized")  = 0
                e.Row("Priority") = True
            Else
                e.Row("Priority") = False
            End If
           
            
            dt.Save()
        End If
    
End If

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


加好友 发短信
等级:超级版主 帖子:109489 积分:557107 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2021/4/13 21:51:00 [只看该作者]

If e.Col.Name = "Priority" Then
    Dim cmd As new SQLCommand
    Dim dt As DataTable
    cmd.CommandText = "Se lect * From {t_SupplyEntry} Where FItemID = '" & e.Row ("FItemID") & "'and FPrioritized = 1"
      cmd.C
    dt = cmd.ExecuteReader(True)
    If dt .datarows.Count > 0 Then
            If MessageBox.Show("该产品已经设定过优先次序了,是否需要把原来的优先次序去除,重新设定当前产品为订单优先 ?","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question) = DialogResult.Yes Then
                
               dt .datarows(0)("FPrioritized")  = 0
            dt.Save()
                e.Row("Priority") = True
            Else
                e.Row("Priority") = False
            End If

        End If
    
End If

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


加好友 发短信
等级:三尾狐 帖子:799 积分:5921 威望:0 精华:0 注册:2018/11/3 8:24:00
  发帖心情 Post By:2021/4/14 21:58:00 [只看该作者]

谢谢,老师, dt .datarows.Count > 0 Then 这个可以找出好多条记录,把找到的所有的记录改做这样的修改 dt .datarows(0)("FPrioritized")  = 0。 现只可更改一笔记录。谢谢。

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


加好友 发短信
等级:超级版主 帖子:109489 积分:557107 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2021/4/15 9:05:00 [只看该作者]


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


加好友 发短信
等级:三尾狐 帖子:799 积分:5921 威望:0 精华:0 注册:2018/11/3 8:24:00
  发帖心情 Post By:2021/4/15 19:44:00 [只看该作者]

老师,如下有点不对,请指正,谢谢。


    If dt.datarows.Count > 0 Then
        
        
        
        If MessageBox.Show("该产品已经设定过优先次序了,是否需要把原来的优先次序去除,重新设定当前产品为订单优先 ?","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question) = DialogResult.Yes Then
            
            For Each dr As DataRow In Dt.DataRows
                
                dt.datarows(0)("FPrioritized")  = 0
                dt.Save()
                e.Row("Priority") = True
            Next
        Else
            e.Row("Priority") = False
        
            
        End If
        
        
        
    End If
    
End If


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


加好友 发短信
等级:超级版主 帖子:109489 积分:557107 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2021/4/15 20:23:00 [只看该作者]

            For Each dr As DataRow In Dt.DataRows
                
                dr("FPrioritized")  = 0

                e.Row("Priority") = True
            Next
                dt.Save()

 回到顶部