Foxtable(狐表)用户栏目专家坐堂 → 批量添加数据后自动编号问题


  共有2563人关注过本帖平板打印复制链接

主题:批量添加数据后自动编号问题

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


加好友 发短信
等级:八尾狐 帖子:1989 积分:12631 威望:0 精华:0 注册:2017/4/3 15:01:00
批量添加数据后自动编号问题  发帖心情 Post By:2019/1/7 0:57:00 [只看该作者]

在DataRowAdded事件中写了如下代码后,批量入库后,自动编号怎么不起作用呢?

Dim dt As DataTable = DataTables("库存资料")
Dim max  As  String
Dim idx  As  Integer
max = dt.Compute("Max(机具ID)","机具ID like 'JJ%'")
If max > ""  Then  '如果存在最大编号
    idx = CInt(max.Substring(2)) + 1 

Else
    idx = 1 

End  If
For Each dr As DataRow In dt.Select("机具ID is null")
    Dim str As String = "JJ" & Format(idx,"000000")
    Dim fdr As DataRow = dt.find("机具ID = '" & str & "'")
    If fdr Is Nothing
        dr("机具ID") = str
    End If
    idx += 1
Next


 回到顶部