有点甜老师:你好!我需要查询 订单中每个产品ID 的最后一行并保存dt中,然后填充到订单查询表中。麻烦修改 jb.Filter的表达式
Dim QueryMonth As Date '自定义日期
QueryMonth=Forms("订单查询").Controls("日期").value
Dim jb As New
SQLJoinTableBuilder("查询表1","订单")
Dim dt As DataTable
jb.ConnectionName = "Sale"
jb.AddTable("订单","产品ID","产品","产品ID")
jb.AddCols("产品名称", "日期", "数量","单价")
jb.Filter = “ {订单}.产品ID = ‘ “ & 产品ID & ”’ and {订单}.日期 < '" & QueryMonth & " ' ,"{订单}.日期 desc" ” ' 这里的表达式如何修改?
jb.Build()
dt = jd.Build(True)
Dim Vals As List(of String())
Vals = dt1.GetValues("产品ID|产品名称|数量|单价")
Dim cmd As new sqlcommand
cmd.C
cmd.CommandText = "select * f rom {订单查询}"
Dim dt2 As DataTable = cmd.ExecuteReader(True)
For i As Integer = 0 To Vals.Count - 1
Dim dr As DataRow = dt2.AddNew()
dr("日期") = QueryMonth
dr("产品ID") = Vals(i)(0)
dr("产品名称") = Vals(i)(1)
dr("数量") = Vals(i)(2)
dr("单价") = Vals(i)(3)
Next
dt2.save