Dim cmd As New SQLCommand
cmd.C
cmd.CommandText = "Sel ect v.* "
cmd.CommandText &= ", a.ID as 任务ID,a.车间 as 车间,a.组别 as 组别,a.单据类型 As 单据类型,a.制单 as 制单,a.审核 as 审核"
cmd.CommandText &= " fro m [" & Vars("mes") & "].dbo.生产发料单 as v "
cmd.CommandText &= " left join [" & Vars("mes") & "].dbo.生产任务单 As a on a.任务单号 = v.任务单号 and a.子阶ID = v.物料ID and v.车间 = a.车间 and v.组别 = a.组别 "
cmd.CommandText &= " where v.批次号 = " & e.Form.Controls("Text批次号").text
Dim tb As Table = Tables(e.Form.Name & "_Table1")
tb.DataSource = cmd.ExecuteReader
此主题相关图片如下:无标题.png
代码如红色字体所示,这样加载进来会有重复的数据,因为生产任务单会有同样的数据多条,
以下代码出现错误!
Dim cmd As New SQLCommand
cmd.C
cmd.CommandText = "Sel ect v.* "
cmd.CommandText &= “ (sele ct a.ID as 任务ID,a.车间 as 车间,a.组别 as 组别,a.单据类型 As 单据类型,a.制单 as 制单,a.审核 as 审核 from [" & Vars("mes") & "].dbo.生产任务单 As a on a.任务单号 = v.任务单号 and a.子阶ID = v.物料ID and v.车间 = a.车间 and v.组别 = a.组别) "
cmd.CommandText &= " fr om [" & Vars("mes") & "].dbo.生产发料单 as v "
cmd.CommandText &= " where v.批次号 = " & e.Form.Controls("Text批次号").text
Dim tb As Table = Tables(e.Form.Name & "_Table1")
tb.DataSource = cmd.ExecuteReader