以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  这个代码有什么问题,重复写入两个相同的数据到json包  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=123701)

--  作者:blackzhu
--  发布时间:2018/8/21 15:13:00
--  这个代码有什么问题,重复写入两个相同的数据到json包
 Dim ja As New JArray
Dim jo2 As New JObject
Dim jo As New JObject
For Each cl As Col In Tables("排版表").Cols
    jo2(cl.Name) = cl.Name.ToString
Next
ja.Add(jo2)
jo("headers") = ja
ft = "日期>=\'" & dt1 & " 00:00:00\' And 日期<=\'" & dt2 & " 23:59:59\'"
If ks > "" Then
    If ft > "" Then
        ft = ft & " And "
    End If
    ft = ft & "科室  = \'" & ks & "\'"
End If
Dim cmd As New SQLCommand
Dim dt As DataTable
cmd.C
cmd.CommandText = "SE                   LECT * From 科室排班 where " & ft & " And 分院=\'" & fy & "\'"
dt = cmd.ExecuteReader()
For Each xm As String In dt.GetValues("姓名", "", "日期")
    Dim nr As Row = Tables("排版表").AddNew
    nr("姓名") = xm
    For Each dr As DataRow In dt.Select("姓名 = \'" & xm & "\'", "日期")
        nr(dr("日期")) = dr("排班")
    Next
Next
ja = New JArray
jo2 = New JObject
For Each dr As DataRow In DataTables("排版表").Select("姓名 Is Not Null", "姓名")
    For Each cl As DataCol In DataTables("排版表").DataCols
        jo2(cl.Name) = dr(cl.Name).ToString
    Next
    ja.Add(jo2)
Next
jo("bodys") = ja
Dim json As String = jo.ToString
Output.show(json)

[此贴子已经被作者于2018/8/21 15:13:31编辑过]

--  作者:blackzhu
--  发布时间:2018/8/21 15:16:00
--  
 数据是这样的:  火狐居然传不上图片

姓名    08-01   08-02

A        病假    正常班
B       正常班  病假
C       病假     正常班

 这个代码 把  C连续写入两次  而 A没有,B正常写入

--  作者:blackzhu
--  发布时间:2018/8/21 15:22:00
--  
 搞定了,添加ja 顺序错了