以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  _SortKey的列如何获取?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=108634)

--  作者:happyft
--  发布时间:2017/10/26 11:31:00
--  _SortKey的列如何获取?
用的是sql拼接字符保存,但遍历时_SortKey这个系统列没有,但用户有时会上下移动行位置,这样保存不了行位置的改变

Dim str2 As String = ""
For Each dc As DataCol In tb.dataCols
        If dc.IsBoolean Then
            If r(dc.Name) = True Then
                str2 + = 1 & ","
            Else
                str2 + = 0 & ","
            End If
        ElseIf dc.IsNumeric Then
            str2 + = r(dc.Name) & ","
        Else \'日期或字符字段
            If r(dc.Name) = Nothing Then 
                str2 + = "Null" &  ","
            Else
                str2 + = "\'" & r(dc.Name) & "\',"
            End If
        End If
Next
上面遍历时datacols中没有此列
要怎么样才能得到这个列?
谢谢!

--  作者:有点甜
--  发布时间:2017/10/26 11:56:00
--  

你可以判断一下是否有 _sortkey 列

 

Dim tb As DataTable = DataTables("表A")
If tb.basetable.columns.contains("_Sortkey") Then
    msgbox("_Sortkey")
End If
If tb.basetable.columns.contains("_Locked") Then
    msgbox("_Locked")
End If


--  作者:HappyFt
--  发布时间:2017/10/26 15:40:00
--  
这样是可以看到,请教这种方式要如何遍历每列,并且判断列是什么类型?

Dim tb As DataTable = DataTables("表A")
For Each dc As DataCol In tb.basetable.columns
  If dc.IsBoolean Then
....
  End if
Next

--  作者:有点甜
--  发布时间:2017/10/26 15:57:00
--  

Dim tb As DataTable = DataTables("表A")

For Each dc As object In tb.basetable.columns
    output.show(dc.ColumnName & " " & dc.DataType.name)
Next


--  作者:HappyFt
--  发布时间:2017/10/26 18:19:00
--  
因为遍历会多了其他一些默认的系统出来,还要每个去排除,每个表都确定有_SortKey列
所以想问下每行获取那列列值要怎么写,
Dim tb As DataTable = DataTables("表A")
dim r as row = tables("表A").current

msgbox(r(tb.basetable.columns("_SortKey")))

普通表这样就可以 msgbox(r("_SortKey")) ,直接引用后台表那列写出来总出错

谢谢!





--  作者:有点甜
--  发布时间:2017/10/26 18:41:00
--  

哪句代码,报什么错?直接写 msgbox(r("_SortKey")) 为什么有问题?


--  作者:HappyFt
--  发布时间:2017/10/26 18:53:00
--  
自己弄复杂了,我以为遍历时没显示这列就不能这样用,原来直接写就可以了,绕一大圈,谢谢老师了!