请教大师,下边代码能合并吗,如何合并,同一个数据源Dim cmd1 As New SQLCommand
Dim cmd2 As New SQLCommand
Dim sql As DataTable
Dim sqlf As DataTable
cmd1.C
cmd2.C
cmd1.CommandText = "Selec t 接单日期,{接单登记}.接单单号,客户名称,产品名称,规格型号,单位,单价,销售数量,发货数量 as 已发货数量,(销售数量 - 发货数量) AS 未发货数量 Fro m ({接单登记} Inner JOIN {接单明细} ON {接单明细}.[接单单号] = {接单登记}.[接单单号]) ORDER BY 接单日期"
cmd2.CommandText = "Selec t 发货日期,{发货表}.发货单号,{发货表}.接单单号,{发货表}.客户名称,产品名称,规格型号,单位,发货数量,接单日期 Fro m ({发货表} Inner JOIN {发货明细} ON {发货明细}.[发货单号] = {发货表}.[发货单号]) inner join {接单登记} on {接单登记}.接单单号 = {发货表}.接单单号 ORDER BY 发货日期"
sql = cmd1.ExecuteReader()
sqlf = cmd2.ExecuteReader()
[此贴子已经被作者于2024/12/12 9:02:42编辑过]
Dim cmd1 As New SQLCommandcmd1.ConnectionName = “xxx”
cmd1.CommandText = "Selec t 接单日期,{接单登记}.接单单号,客户名称,产品名称,规格型号,单位,单价,销售数量,发货数量 as 已发货数量,(销售数量 - 发货数量) AS 未发货数量 Fro m ({接单登记} Inner JOIN {接单明细} ON {接单明细}.[接单单号] = {接单登记}.[接单单号]) ORDER BY 接单日期"
Dim sql As DataTable = cmd1.ExecuteReader()
cmd1.CommandText ="Selec t 发货日期,{发货表}.发货单号,{发货表}.接单单号,{发货表}.客户名称,产品名称,规格型号,单位,发货数量,接单日期 Fro m ({发货表} Inner JOIN {发货明细} ON {发货明细}.[发货单号] = {发货表}.[发货单号]) inner join {接单登记} on {接单登记}.接单单号 = {发货表}.接单单号 ORDER BY 发货日期"
Dim sqlf As DataTable = cmd1.ExecuteReader()
在运行中,上边的代码可以,换成下边的代码则出错,请教能有什么原因
Dim bd1 As New CrossTableBuilder("统计表1", sql,"sale")
Dim sql As String = "Selec t 接单日期,{接单登记}.接单单号,客户名称,产品名称,规格型号,单位,单价,销售数量,发货数量 as 已发货数量,(销售数量 - 发货数量) AS 未发货数量 Fro m ({接单登记} Inner JOIN {接单明细} ON {接单明细}.[接单单号] = {接单登记}.[接单单号]) ORDER BY 接单日期"
Dim sqlf As String = "Selec t 发货日期,{发货表}.发货单号,{发货表}.接单单号,{发货表}.客户名称,产品名称,规格型号,单位,发货数量,接单日期 Fro m ({发货表} Inner JOIN {发货明细} ON {发货明细}.[发货单号] = {发货表}.[发货单号]) inner join {接单登记} on {接单登记}.接单单号 = {发货表}.接单单号 ORDER BY 发货日期"
Dim bd1 As New CrossTableBuilder("统计表1", sql,"sale")
Dim dt1 As fxDataSource
bd1.HGroups.AddDef("接单日期", DateGroupEnum.none)
bd1.HGroups.AddDef("接单单号")
bd1.HGroups.AddDef("客户名称")
bd1.HGroups.AddDef("产品名称") '添加客户列用于水平分组
bd1.HGroups.AddDef("规格型号") '添加客户列用于水平分组
bd1.HGroups.AddDef("单位") '添加客户列用于水平分组
bd1.HGroups.AddDef("销售数量")
bd1.HGroups.AddDef("已发货数量")
bd1.HGroups.AddDef("未发货数量")
dt1 = bd1.BuildDataSource()
Dim bd2 As New CrossTableBuilder("统计表2", sqlf,"sale")
Dim dt2 As fxDataSource
bd2.HGroups.AddDef("接单日期", DateGroupEnum.none)
bd2.HGroups.AddDef("接单单号")
bd2.HGroups.AddDef("客户名称")
bd2.HGroups.AddDef("产品名称") '添加客户列用于水平分组
bd2.HGroups.AddDef("规格型号") '添加客户列用于水平分组
bd2.HGroups.AddDef("单位") '添加客户列用于水平分组
bd2.VGroups.AddDef("发货日期", DateGroupEnum.none)
bd2.Totals.AddDef("发货数量")
dt2 = bd2.BuildDataSource()
Dim nms As String() = {"接单日期", "接单单号", "客户名称", "产品名称", "规格型号", "单位" }
dt1.Combine(nms, dt2, nms)
Tables("统计汇总_Table3").DataSource = dt1
bd1.HGroups.AddDef("销售数量")
bd1.HGroups.AddDef("已发货数量")
bd1.HGroups.AddDef("未发货数量")
改为
bd1.VGroups.AddDef("销售数量")
bd1.VGroups.AddDef("已发货数量")
bd1.VGroups.AddDef("未发货数量")