Foxtable(狐表)用户栏目专家坐堂 → 关于临时表的主键字段


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

主题:关于临时表的主键字段

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


加好友 发短信
等级:小狐 帖子:392 积分:3312 威望:0 精华:0 注册:2014/4/9 10:04:00
关于临时表的主键字段  发帖心情 Post By:2021/6/2 16:24:00 [只看该作者]

下面代码中涉及到“_Identify”字段,请问老师临时表如何拥有这样一个相同功能的“_Identify”字段?(主键)

Dim idx As String = "-1,"
Dim idx_temp As String = ""
Dim pdr As DataRow = Nothing
Dim count As Integer = 0
Dim cs As String = "字段1"
For Each dr As DataRow In DataTables("table1").Select("", cs)
    Dim flag As Boolean = False
    If pdr IsNot Nothing Then
        For Each c As String In cs.split(",")
            If pdr(c).replace(" ","") <> dr(c).replace(" ", "") Then
                flag = True
                Exit For
            End If
        Next
        If flag Then
            If count > 1 Then
                idx &= idx_temp
            End If
            count = 1
            idx_temp = ""
        Else
            count += 1
            idx_temp &= dr("_Identify") & ","
        End If
    Else
        count += 1
    End If
    pdr = dr
Next
If count > 1 Then
    idx &= idx_temp
End If
Tables("table1").filter = "_Identify not In (" & idx.trim(",") & ")"

 回到顶部
帅哥,在线噢!
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


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

什么样的临时表,怎么创建的表?

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


加好友 发短信
等级:小狐 帖子:392 积分:3312 威望:0 精华:0 注册:2014/4/9 10:04:00
  发帖心情 Post By:2021/6/2 16:45:00 [只看该作者]

If  Tables.Contains("临时表") = False Then
    
    Dim dtb As New DataTableBuilder("临时表")
    dtb.AddDef("字段1", Gettype(String),500)
    dtb.AddDef("字段2", Gettype(String),500)

    dtb.Build()
    MainTable= Tables("临时表")
    
End If

然后用TABLES("临时表").Addnew加的数据

 回到顶部
帅哥,在线噢!
有点蓝
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


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

Dim dtb As New DataTableBuilder("临时表")
dtb.AddDef("_Identify", Gettype(Integer))
dtb.AddDef("字段1", Gettype(String),500)
dtb.AddDef("字段2", Gettype(String),500)
dtb.Build()
DataTables("临时表").basetable.Columns("_Identify").AutoIncrement = True
DataTables("临时表").basetable.Columns("_Identify").AutoIncrementSeed = 1
MainTable= Tables("临时表")

Dim r As Row = Tables("临时表").AddNew
Output.Show(r("_Identify"))
r = Tables("临时表").AddNew
Output.Show(r("_Identify"))

 回到顶部