以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  find语句  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=138269)

--  作者:北狐
--  发布时间:2019/7/26 18:13:00
--  find语句
Dim xsml As New SQLCommand   \'销售明细表
Dim ml As DataTable
Dim sCols() As String = {"本单单号","销售金额"}
Dim dCols() As String = {"本单单号","销售金额"}

xsml.C
xsml.CommandText = "查询语句过长,已确认语句无误,以此替代"
ml = xsml.ExecuteReader()
For Each dr As DataRow In ml.DataRows
    If DataTables("销售主表").Find("(本单单号 = \'" & dr("本单单号") & "\'“) IsNot Nothing  Then  (请问老师,如何只合并与销售主表中是否检查(逻辑列)已勾选(True)时对应行的本单单号相同的数据到销售明细表)
        Dim nr As DataRow = DataTables("销售明细表").AddNew()
        For i As Integer =0 To sCols.Length -1
            nr(dCols(i)) = dr(sCols(i))
        Next
    End If
Next


--  作者:有点蓝
--  发布时间:2019/7/26 20:40:00
--  
逻辑反了吧,直接根据勾选的单号查询出数据,然后填充就行了

Dim ids As String = ""
For Each dr As DataRow In DataTables("销售主表").Select("是否检查=true")
    ids = ids & ",\'" & dr("本单单号") & "\'"
Next
ids= ids.Trim(",")
msgbox(ids)

xsml.CommandText = "查询语句过长,已确认语句无误,以此替代 where 本单单号 in(" & ids & ")"