根据表中guid不重复值,进行数据查找统计,结果只统计了第一个guid的数据
麻烦老师们指导下 谢谢!
当前代码如下:
Dim cmd As new SQLCommand
cmd.Conn ect i
cmd.CommandText ="se lect * from {监督任务台账}"
Dim dt2 As DataTable = cmd.ExecuteReader()
Dim Products As List(Of String)
Products = dt2.GetValues("guid")
For Each Product As String In Products
output.show(Product)
cmd.CommandText ="sel ect guid from {日常监督检查登记台账} where 主表guid='" & Product & "'"
Dim Values = cmd.ExecuteValues
If Values.Count > 0 Then
output.show(Values("Guid"))
Dim d1,d2,d3,d4,d5 As Integer
d1=Values.Count
output.show(d1)
cmd.CommandText ="sel ect * from {监督发现问题台账} where 主表guid='" & Values("Guid") & "'"
output.show(cmd.CommandText)
Dim dt1 As DataTable = cmd.ExecuteReader()
If dt1.DataRows.Count>0 Then
d2=dt1.DataRows.Count
output.show(d2)
End If
cmd.CommandText ="sele ct * from {监督发现问题台账} where 办理情况='已经办结' and 主表guid='" & Values("Guid") & "'"
output.show(cmd.CommandText)
Dim dt21 As DataTable = cmd.ExecuteReader()
If dt21.DataRows.Count>0 Then
d3=dt21.DataRows.Count
output.show(d3)
End If
cmd.CommandText ="upd ate {监督任务台账} set 检查数='" & d1 & "',问题数='" & d2 & "',已处理数='" & d3 & "' where guid='" & Product & "'"
output.show(cmd.CommandText)
cmd.ExecuteNonQuery()
End If
Next
运行结果如下:
9cf7cb6b-8651-4365-9524-ec030d508d1a
d754f780-2291-4553-827b-8e20669376a7
1
sel ect * from {监督发现问题台账} where 主表guid='d754f780-2291-4553-827b-8e20669376a7'
2
sel ect * from {监督发现问题台账} where 办理情况='已经办结' and 主表guid='d754f780-2291-4553-827b-8e20669376a7'
1
updat e {监督任务台账} set 检查数='1',问题数='2',已处理数='1' where guid='9cf7cb6b-8651-4365-9524-ec030d508d1a'
af404380-f500-4202-b21d-93ed9d9b6894
b8aba3c2-8cc9-43a7-8c32-d9a03fae74e5
d0dadb3f-357f-48e7-8c11-d8f051e5214d
d67349ea-39b5-4ad9-82dd-8334e4dc38e9