以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  treeview 出错  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=50608)

--  作者:yedaoan
--  发布时间:2014/5/9 16:57:00
--  treeview 出错

Dim cmd As New SQLCommand
Dim dt As DataTable
cmd.C
cmd.CommandText = "SELECT GY_LZFS.FSMC, CP_CK01.SHSJ, CP_CPZD.CPBM, CP_CPZD.CPMC, CP_CPZD.CPGG, CP_CPZD.CPYS, CP_CPZD.CPDW, CP_CK02.DHDH, CP_CK02.CPSL, CP_CK02.JSJG, CP_CK02.JSJE, CP_JGXX.XSJG, CP_CK02.DHDH" _
                  & " FROM ((GY_LZFS INNER JOIN (CP_CK01 INNER JOIN CP_CK02 ON (CP_CK01.LZDH = CP_CK02.LZDH) And (CP_CK01.LZFS = CP_CK02.LZFS)) ON GY_LZFS.LZFS = CP_CK01.LZFS) INNER JOIN CP_CPZD ON CP_CK02.CPXH = CP_CPZD.CPXH) INNER JOIN CP_JGXX ON CP_CK02.CPXH = CP_JGXX.CPXH" _
                  & " WHERE (((GY_LZFS.FSMC)=\'销售出库\') AND ((CP_JGXX.XSLX)=2) AND ((CP_CK01.DJZT)=\'AU\'));"
dt = cmd.ExecuteReader()
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
trv.BuildTree(dt,"SHSJ YM")
trv.Nodes.Insert("加载所有数据",0)

 

在窗体的afterload事件,加入上述代码,想按时间来显示,结果老提示  无效列名 SHSJ YM ,改成  trv.BuildTree(dt,"SHSJ") 这样不会提示,但是我要按月显示树,问题在哪里?


--  作者:Bin
--  发布时间:2014/5/9 16:57:00
--  
列名是不可以有空格的.
--  作者:Bin
--  发布时间:2014/5/9 16:58:00
--  
想按年月,首先查询表就要按年月查询

[此贴子已经被作者于2014-5-9 16:58:35编辑过]

--  作者:有点甜
--  发布时间:2014/5/9 17:00:00
--  

 呃,需要这样写

 

cmd.CommandText = "SELECT Year(CP_CK01.SHSJ) As 年, Month(CP_CK01.SHSJ) As 月, GY_LZFS.FSMC, CP_CK01.SHSJ, CP_CPZD.CPBM, CP_CPZD.CPMC, CP_CPZD.CPGG, CP_CPZD.CPYS, CP_CPZD.CPDW, CP_CK02.DHDH, CP_CK02.CPSL, CP_CK02.JSJG, CP_CK02.JSJE, CP_JGXX.XSJG, CP_CK02.DHDH" _
                  & " FROM ((GY_LZFS INNER JOIN (CP_CK01 INNER JOIN CP_CK02 ON (CP_CK01.LZDH = CP_CK02.LZDH) And (CP_CK01.LZFS = CP_CK02.LZFS)) ON GY_LZFS.LZFS = CP_CK01.LZFS) INNER JOIN CP_CPZD ON CP_CK02.CPXH = CP_CPZD.CPXH) INNER JOIN CP_JGXX ON CP_CK02.CPXH = CP_JGXX.CPXH" _
                  & " WHERE (((GY_LZFS.FSMC)=\'销售出库\') AND ((CP_JGXX.XSLX)=2) AND ((CP_CK01.DJZT)=\'AU\'));"
dt = cmd.ExecuteReader()
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
trv.BuildTree(dt,"年|月")
trv.Nodes.Insert("加载所有数据",0)

[此贴子已经被作者于2014-5-9 17:01:13编辑过]