以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  请教空行  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=89577)

--  作者:hbhb
--  发布时间:2016/8/24 20:26:00
--  请教空行
大师:请问如何控制一张表的满足下列要求的代码,劳驾指导一下。
1、如果一行有任意记录,则不能有任意一列记录为空的
2、如果一行没有任何记录,保存时就删除这些行




--  作者:大红袍
--  发布时间:2016/8/24 21:09:00
--  

 1、

 

Dim dt As DataTable = DataTables("表A")
For Each dr As DataRow In dt.datarows
    Dim flag As Boolean = True
    For Each dc As DataCol In dt.datacols
        If dr.IsNull(dc.name) = False Then
            flag = False
        ElseIf flag = False Then
            msgbox(dr("_Identify") & "行" & dc.name & "为空")
            Return ""
        End If
    Next
Next

 

 2、

 

Dim dt As DataTable = DataTables("表A")
Dim idxs As String = "-1,"

For Each dr As DataRow In dt.datarows
    Dim flag As Boolean = True
    For Each dc As DataCol In dt.datacols
        If dr.IsNull(dc.name) = False Then
            flag = False
        End If
    Next
    If flag Then
        idxs &= dr("_Identify") & ","
    End If
Next
dt.DeleteFor("_Identify in (" & idxs.trim(",") & ")")


--  作者:hbhb
--  发布时间:2016/8/24 21:38:00
--  
谢谢!能否通过行状态属性进行判断,代码是否少些?
--  作者:大红袍
--  发布时间:2016/8/24 21:59:00
--  
 不可以。