Foxtable(狐表)用户栏目专家坐堂 → [求助]我用sql加载的表格,怎么用不了AppendLoad追载数据?


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

主题:[求助]我用sql加载的表格,怎么用不了AppendLoad追载数据?

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


加好友 发短信
等级:六尾狐 帖子:1465 积分:10397 威望:0 精华:0 注册:2018/10/16 11:42:00
[求助]我用sql加载的表格,怎么用不了AppendLoad追载数据?  发帖心情 Post By:2022/8/22 10:11:00 [只看该作者]

我是用这个办法加载的表、但是用AppendLoad(Filter,Save)追载不了数据,是怎么回事?
Dim cmd As new SQLCommand
cmd.ConnectionName = "SQL"
cmd.CommandText = "Select * From {叮咚聊天} Where [发送人]='" & _账户ID & "' or [接收人]='" & _账户ID & "'"
Dim dt As DataTable = cmd.ExecuteReader(True)
Tables("叮咚聊天_Table1").DataSource = dt
DataTables("叮咚聊天_Table1").AllowEdit = True '取消冻结表
DataTables("叮咚聊天_Table1").DataCols("发送时间").SetDateTimeFormat(DateTimeFormatEnum.DateLongTime)
DataTables("叮咚聊天_Table1").DataCols("已读时间").SetDateTimeFormat(DateTimeFormatEnum.DateLongTime)
DataTables("叮咚聊天_Table1").DataCols.Add("聊天记录", Gettype(String),999999 )






计划管理

'''
If Forms("叮咚聊天").Opened Then
    Dim 内容 As String=""
    '''
    Dim id As Integer = DataTables("叮咚聊天_Table1").Compute("Max(_Identify)")
    Dim Filter As String = "已读人='' and 接收人='" & _账户ID & "' "
    DataTables("叮咚聊天_Table1").AppendLoad(Filter, False)
    
    For Each r As Row In Tables("叮咚聊天_Table1").Rows
        
        Dim 联系,已读,接收 As String
        联系=""
        已读=""
        接收=""
        Dim dr As DataRow = DataTables("叮咚好友").Find("联系人 = '" & r("发送人") & "'" )
        If dr IsNot Nothing Then '如果找到的话
            联系=dr("好友备注")
        Else
            联系= r("发送人")
        End If
        Dim dr0 As DataRow = DataTables("叮咚好友").Find("联系人 = '" & r("接收人") & "'" )
        If dr0 IsNot Nothing Then '如果找到的话
            接收=dr0("好友备注")
        Else
            接收= r("接收人")
        End If
        If r.IsNull("已读人") Then
            已读="□"
            内容= 内容 & vbcrlf & vbcrlf  & 联系 & " " &  r("发送时间") & vbcrlf & r("发送内容")
        Else
            
            已读="?"
        End If
        
        
        r("聊天记录")="[" & 联系 & "]→[" & 接收 &  "]    " & r("发送时间") & "    " & 已读 & vbcrlf & "  " & r("发送内容")
        Forms("叮咚聊天").Controls("新消息提醒").Visible=True
        r("已读人")=_账户ID
        r.Save
    Next
    If 内容="" Then
    Else
        Myform.Msgbox( 内容 ,"您有新的叮咚消息!" ,True)
    End If
    Dim Products As List(Of String)
    Products = DataTables("叮咚好友").GetValues("类型")
    For Each Product As String In Products
        '找出所有的类型Product
        Dim Page As WinForm.TopicPage
        Page = Forms("叮咚聊天").Controls("TopicBar1").Pages.Add(Product,Product)
        For Each dr As DataRow In DataTables("叮咚好友").DataRows
            If dr("类型")=Product Then
                Dim 未读数 As Integer = 0
                未读数 = DataTables("叮咚聊天_Table1").Compute("Count(发送人)", "发送人 = '" & dr("联系人") & "' and 接收人='" & _账户ID & "' and 已读时间 is null" )
                Dim 未读 As String
                If 未读数>0 Then
                    未读 ="("& 未读数 &")"
                Else
                    未读=""
                End If
                Page.Links.Add( dr("联系人") ,"?" & dr("好友备注")& 未读)
            End If
        Next
        
    Next
End If

[此贴子已经被作者于2022/8/22 10:10:56编辑过]

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


加好友 发短信
等级:超级版主 帖子:106816 积分:543281 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2022/8/22 10:21:00 [只看该作者]

应该是没有符合条件的数据,试试
Dim Filter As String = "(已读人='' or 已读人 is null) and 接收人='" & _账户ID & "' "
msgbox(Filter )

我测试没有问题

窗口afterload
Dim cmd As New SQLCommand
cmd.ConnectionName = "SQL"
cmd.CommandText = "Select * From {用户管理} where 部门名称='业务部'"
Dim dt As DataTable = cmd.ExecuteReader(True)
Tables("窗口1_Table1").DataSource = dt
Tables("窗口1_Table1").AllowEdit=True

追加按钮
dataTables("窗口1_Table1").AppendLoad("部门名称='工程部'",False)

可以看到追加后的数据

 回到顶部