以下是引用muhua在2013-3-19 10:53:00的发言:
Tables("窗口1_Table1").Fill("Select 单价,折扣,数量,日期,产品,客户,雇员 From {订单} a where a.日期 in (Select max(日期) From {订单} Group By 产品)","Sale",True)
这个也试过,但是不是他要的结果,如果把后面的True改为False 则出错了。
Dim strIn As String = ""
Dim cmdText As String = ""
Dim cmd As new SQLCommand
cmd.C
cmd.CommandText = "Select * From {订单} a INNER JOIN (Select Max(日期) As 日期 From {订单} Group By 产品) b on a.日期 = b.日期"
Dim dt As DataTable = cmd.ExecuteReader
For Each dr As DataRow In dt.DataRows
strIn = strIn & "'" & dr("_Identify") & "',"
Next
strIn = strIn.TrimEnd(",")
cmdText = "Select 单价,折扣,数量,日期,产品,客户,雇员,日期 from {订单} where [_Identify] In (" & strIn & ")"
Tables("窗口1_Table1").Fill(cmdText,"Sale",false)
如果是数值,去掉'
[此贴子已经被作者于2013-3-19 11:07:19编辑过]