以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  select  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=55096)

--  作者:bagabaga
--  发布时间:2014/8/10 21:47:00
--  select
请教,有二个表,{QdxrcjhlMx}含有Rcjid,Rcjhl,Rcjhj,fK列,RcjhzMx含有RcjBm,Mc列
1.先选取当前Tables("Qdmx").Current("Xh")对应的{QdxrcjhlMx} 生成临时表
2.根据临时表和RcjhzMx生成统计表
结果出错,请指教

Dim cmd As New SQLCommand
Dim dt1 As DataTable
cmd.CommandText = "SELECT Rcjid,Rcjhl,Rcjhj,fK From {QdxrcjhlMx} where Fk = \'"  & Tables("Qdmx").Current("Xh") & "\'"
dt1 = cmd.ExecuteReader()


Dim sql As String = "Select RcjBm,Mc,Rcjhl,Rcjhj FROM {dt1} INNER JOIN {RcjhzMx} ON {dt1}.RcjId = {RcjhzMx}.RcjId"
Dim b As New GroupTableBuilder("统计表1",sql) 
b.Groups.AddDef("RcjBm")
b.Groups.AddDef("Mc") 
b.Groups.AddDef("Rcjhl") 
b.Totals.AddDef("rcjhj")
\'b.HorizontalTotal = True
b.VerticalTotal = True
b.Build()
MainTable = Tables("统计表1")






--  作者:有点甜
--  发布时间:2014/8/10 21:51:00
--  

不能分开写

 

Dim sql As String = "Select RcjBm,Mc,Rcjhl,Rcjhj FROM (SELECT Rcjid,Rcjhl,Rcjhj,fK From {QdxrcjhlMx} where Fk = \'"  & Tables("Qdmx").Current("Xh") & "\') as a INNER JOIN {RcjhzMx} as b ON a.RcjId = b.RcjId"
Dim b As New GroupTableBuilder("统计表1",sql)
b.Groups.AddDef("RcjBm")
b.Groups.AddDef("Mc")
b.Groups.AddDef("Rcjhl")
b.Totals.AddDef("rcjhj")
\'b.HorizontalTotal = True
b.VerticalTotal = True
b.Build()
MainTable = Tables("统计表1")