以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- Dim Cols1() As String = {"编码","EquipmentID","标志","dt_BeginDate","状态"} 如何定义表中无对应字段 值的组合呢? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=170054) |
-- 作者:cnsjroom -- 发布时间:2021/7/9 20:34:00 -- Dim Cols1() As String = {"编码","EquipmentID","标志","dt_BeginDate","状态"} 如何定义表中无对应字段 值的组合呢? Dim Cols1() As String = {"编码","EquipmentID","标志","dt_BeginDate","状态"} 如何定义表中无对应字段 值的组合呢? Dim 标志 As String Dim 编码 As String ="10010" Dim 状态 As String Dim Products As List(Of String) Products = DataTables("m_Localizer").SQLGetValues("ID") For Each Product As String In Products \'Output.Show(Product) Dim dr As DataRow dr = DataTables("Alarm_Current").Find("AlarmTypeID=\'1001\' And EquipmentID=\'" & Product & "\'") If dr IsNot Nothing \'如果找到, 则设置各列内容 标志="100" 状态="正常" Else 标志="200" 状态="异常" End If Next Dim c As Integer =DataTables("m_Localizer").Compute("count(vc_Name)") output.show(c) Dim Cols1() As String = {"编码","EquipmentID","标志","dt_BeginDate","状态"} Dim s As String s=Date.now() & "," & c s = s.TrimStart(",") FileSys.WriteAllText("D:\\persionLoaction\\Data\\DeviceStatus.txt",s & vbcrlf,False) For Each dr As DataRow In DataTables("m_Localizer").DataRows s = "" For i As Integer = 0 To Cols1.Length -1 If s > "" Then s = s & "," If dr.IsNull(Cols1(i)) = False Then s = s & dr(Cols1(i)) End If Next s = s.TrimStart(",") FileSys.WriteAllText("D:\\persionLoaction\\Data\\DeviceStatus.txt", s & vbcrlf , True, Encoding.Default) Next 想实现如下内容输出,上述代码怎么修改呢? 2021-07-08 11:05:29,13 "编码","EquipmentID","标志","dt_BeginDate","状态" 10010,11,100,2021-07-08 11:05:29,正常 10010,21,100,2021-07-08 11:05:29,正常 10010,31,100,2021-07-08 11:05:29,正常 10010,52,100,2021-07-08 11:05:29,正常 10010,53,100,2021-07-08 11:05:29,正常 10010,61,100,2021-07-08 11:05:29,正常 10010,63,100,2021-07-08 11:05:29,正常 10010,71,100,2021-07-08 11:05:29,正常 10010,72,100,2021-07-08 11:05:29,正常 10010,101,100,2021-07-08 11:05:29,正常 10010,102,100,2021-07-08 11:05:29,正常 10010,103,100,2021-07-08 11:05:29,正常 10010,106,100,2021-07-08 11:05:29,正常 |
-- 作者:有点蓝 -- 发布时间:2021/7/10 9:18:00 -- Dim Cols1() As String = {编码,"EquipmentID",标志,"dt_BeginDate",状态} …… For i As Integer = 0 To Cols1.Length -1 If s > "" Then s = s & "," If DataTables("m_Localizer").DataCols.Contains(Cols1(i)) if dr.IsNull(Cols1(i)) = False Then s = s & dr(Cols1(i)) end if else s = s & Cols1(i) End If Next [此贴子已经被作者于2021/7/10 9:21:20编辑过]
|