Dim frmname As String=e.Form.name
Dim tbl As Table = Tables(frmname & "_table1")
If tbl.GetCheckedRows().count=0 Then
messagebox.show("请选择工厂订单")
Else
Dim gcr As List(of Row) = tbl.GetCheckedRows()
Dim s As String
For Each r As Row In gcr
s = s & "'" & r("planid") & "',"
Next
Dim st As String
st = ";with cte As (select aec00000.planid,abe00000.*,cast(abe00000.num as numeric(18,4)) As CalcNum from abe00000 join aec00000 on abe00000.parentitem = aec00000.itemcode join eba00000 on aec00000.id_contract = eba00000.id_contract where aec00000.planid in (" & s.Trim(",") & ") union all select cte.planid,a.*,cast(a.num * cte.CalcNum as numeric(18,4))from abe00000 a Join cte on a.parentitem = cte.childitem)select a.planid,d.requiredate,a.parentitem,b.name,a.childitem,c.name,c.unit,a.CalcNum*d.plannum as totalnum from cte a,aaa00000 b,aaa00000 c,aec00000 d where a.parentitem=b.code and a.childitem=c.code and a.planid=d.planid union all select a.planid,a.requiredate,a.itemcode as parentitem,b.name,a.itemcode as childitem,c.name,c.unit,a.plannum as totalnum from aec00000 a,aaa00000 b,aaa00000 c where planid in (" & s.Trim(",") & ")and a.itemcode=b.code and a.itemcode=c.code"
Tables(frmname & "_table2").fill(st,"erp",True)
End If
怪事,改成fill后又可以附加那段添加序号列的代码了,原来可不是这样的,总提示什么
不支持基于sqlcommand生成的没有基表的数据什么的