以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]我用sql加载的表格,怎么用不了AppendLoad追载数据? (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=179403) |
-- 作者:zto001 -- 发布时间:2022/8/22 10:11:00 -- [求助]我用sql加载的表格,怎么用不了AppendLoad追载数据? 我是用这个办法加载的表、但是用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编辑过]
|
-- 作者:有点蓝 -- 发布时间: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) 可以看到追加后的数据 |